summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib/shared
diff options
context:
space:
mode:
Diffstat (limited to 'tools/designer/src/lib/shared')
-rw-r--r--tools/designer/src/lib/shared/actioneditor.cpp21
-rw-r--r--tools/designer/src/lib/shared/actionrepository.cpp2
-rw-r--r--tools/designer/src/lib/shared/connectionedit.cpp6
-rw-r--r--tools/designer/src/lib/shared/formlayoutmenu.cpp6
-rw-r--r--tools/designer/src/lib/shared/formwindowbase.cpp4
-rw-r--r--tools/designer/src/lib/shared/grid.cpp22
-rw-r--r--tools/designer/src/lib/shared/iconselector.cpp124
-rw-r--r--tools/designer/src/lib/shared/iconselector_p.h30
-rw-r--r--tools/designer/src/lib/shared/layoutinfo.cpp4
-rw-r--r--tools/designer/src/lib/shared/morphmenu.cpp8
-rw-r--r--tools/designer/src/lib/shared/newactiondialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/newactiondialog.ui54
-rw-r--r--tools/designer/src/lib/shared/qdesigner_command.cpp82
-rw-r--r--tools/designer/src/lib/shared/qdesigner_command2.cpp62
-rw-r--r--tools/designer/src/lib/shared/qdesigner_command2_p.h22
-rw-r--r--tools/designer/src/lib/shared/qdesigner_formbuilder.cpp4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp2
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menu.cpp8
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menubar.cpp2
-rw-r--r--tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp12
-rw-r--r--tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h11
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertycommand.cpp28
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertysheet.cpp96
-rw-r--r--tools/designer/src/lib/shared/qdesigner_tabwidget.cpp34
-rw-r--r--tools/designer/src/lib/shared/qdesigner_taskmenu.cpp149
-rw-r--r--tools/designer/src/lib/shared/qdesigner_taskmenu_p.h1
-rw-r--r--tools/designer/src/lib/shared/qdesigner_toolbar.cpp6
-rw-r--r--tools/designer/src/lib/shared/qdesigner_toolbox.cpp24
-rw-r--r--tools/designer/src/lib/shared/qdesigner_utils.cpp248
-rw-r--r--tools/designer/src/lib/shared/qdesigner_utils_p.h32
-rw-r--r--tools/designer/src/lib/shared/qlayout_widget.cpp14
-rw-r--r--tools/designer/src/lib/shared/qtresourcemodel.cpp50
-rw-r--r--tools/designer/src/lib/shared/richtexteditor.cpp202
-rw-r--r--tools/designer/src/lib/shared/richtexteditor_p.h1
-rw-r--r--tools/designer/src/lib/shared/stylesheeteditor.cpp4
-rw-r--r--tools/designer/src/lib/shared/widgetdatabase.cpp10
-rw-r--r--tools/designer/src/lib/shared/widgetfactory.cpp2
-rw-r--r--tools/designer/src/lib/shared/zoomwidget.cpp2
38 files changed, 1055 insertions, 338 deletions
diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp
index 251730e..fb882c3 100644
--- a/tools/designer/src/lib/shared/actioneditor.cpp
+++ b/tools/designer/src/lib/shared/actioneditor.cpp
@@ -288,7 +288,7 @@ void ActionEditor::setFormWindow(QDesignerFormWindowInterface *formWindow)
return;
if (m_formWindow != 0) {
- const ActionList actionList = qFindChildren<QAction*>(m_formWindow->mainContainer());
+ const ActionList actionList = m_formWindow->mainContainer()->findChildren<QAction*>();
foreach (QAction *action, actionList)
disconnect(action, SIGNAL(changed()), this, SLOT(slotActionChanged()));
}
@@ -311,7 +311,7 @@ void ActionEditor::setFormWindow(QDesignerFormWindowInterface *formWindow)
m_actionNew->setEnabled(true);
m_filterWidget->setEnabled(true);
- const ActionList actionList = qFindChildren<QAction*>(formWindow->mainContainer());
+ const ActionList actionList = formWindow->mainContainer()->findChildren<QAction*>();
foreach (QAction *action, actionList)
if (!action->isSeparator() && core()->metaDataBase()->item(action) != 0) {
// Show unless it has a menu. However, listen for change on menu actions also as it might be removed
@@ -445,7 +445,6 @@ void ActionEditor::slotNewAction()
if (dlg.exec() == QDialog::Accepted) {
const ActionData actionData = dlg.actionData();
m_actionView->clearSelection();
-
QAction *action = new QAction(formWindow());
action->setObjectName(actionData.name);
formWindow()->ensureUniqueObjectName(action);
@@ -459,9 +458,9 @@ void ActionEditor::slotNewAction()
setInitialProperty(sheet, QLatin1String(checkablePropertyC), QVariant(true));
if (!actionData.keysequence.value().isEmpty())
- setInitialProperty(sheet, QLatin1String(shortcutPropertyC), qVariantFromValue(actionData.keysequence));
+ setInitialProperty(sheet, QLatin1String(shortcutPropertyC), QVariant::fromValue(actionData.keysequence));
- sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), qVariantFromValue(actionData.icon));
+ sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), QVariant::fromValue(actionData.icon));
AddActionCommand *cmd = new AddActionCommand(formWindow());
cmd->init(action);
@@ -480,13 +479,13 @@ static inline bool isSameIcon(const QIcon &i1, const QIcon &i2)
static QDesignerFormWindowCommand *setIconPropertyCommand(const PropertySheetIconValue &newIcon, QAction *action, QDesignerFormWindowInterface *fw)
{
const QString iconProperty = QLatin1String(iconPropertyC);
- if (newIcon.paths().isEmpty()) {
+ if (newIcon.isEmpty()) {
ResetPropertyCommand *cmd = new ResetPropertyCommand(fw);
cmd->init(action, iconProperty);
return cmd;
}
SetPropertyCommand *cmd = new SetPropertyCommand(fw);
- cmd->init(action, iconProperty, qVariantFromValue(newIcon));
+ cmd->init(action, iconProperty, QVariant::fromValue(newIcon));
return cmd;
}
@@ -502,7 +501,7 @@ static QDesignerFormWindowCommand *setKeySequencePropertyCommand(const PropertyS
return cmd;
}
SetPropertyCommand *cmd = new SetPropertyCommand(fw);
- cmd->init(action, shortcutProperty, qVariantFromValue(ks));
+ cmd->init(action, shortcutProperty, QVariant::fromValue(ks));
return cmd;
}
@@ -528,7 +527,7 @@ static inline QString textPropertyValue(const QDesignerPropertySheetExtension *s
{
const int index = sheet->indexOf(name);
Q_ASSERT(index != -1);
- const PropertySheetStringValue ps = qVariantValue<PropertySheetStringValue>(sheet->property(index));
+ const PropertySheetStringValue ps = qvariant_cast<PropertySheetStringValue>(sheet->property(index));
return ps.value();
}
@@ -545,7 +544,7 @@ void ActionEditor::editAction(QAction *action)
oldActionData.name = action->objectName();
oldActionData.text = action->text();
oldActionData.toolTip = textPropertyValue(sheet, QLatin1String(toolTipPropertyC));
- oldActionData.icon = qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC))));
+ oldActionData.icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC))));
oldActionData.keysequence = ActionModel::actionShortCut(sheet);
oldActionData.checkable = action->isCheckable();
dlg.setActionData(oldActionData);
@@ -677,7 +676,7 @@ void ActionEditor::resourceImageDropped(const QString &path, QAction *action)
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
const PropertySheetIconValue oldIcon =
- qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC))));
+ qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC))));
PropertySheetIconValue newIcon;
newIcon.setPixmap(QIcon::Normal, QIcon::Off, PropertySheetPixmapValue(path));
if (newIcon.paths().isEmpty() || newIcon.paths() == oldIcon.paths())
diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp
index ba00feb..d7701cb 100644
--- a/tools/designer/src/lib/shared/actionrepository.cpp
+++ b/tools/designer/src/lib/shared/actionrepository.cpp
@@ -136,7 +136,7 @@ QModelIndex ActionModel::addAction(QAction *action)
const Qt::ItemFlags flags = Qt::ItemIsSelectable|Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled|Qt::ItemIsEnabled;
QVariant itemData;
- qVariantSetValue(itemData, action);
+ itemData.setValue(action);
for (int i = 0; i < NumColumns; i++) {
QStandardItem *item = new QStandardItem;
diff --git a/tools/designer/src/lib/shared/connectionedit.cpp b/tools/designer/src/lib/shared/connectionedit.cpp
index c193da7..5f5085c 100644
--- a/tools/designer/src/lib/shared/connectionedit.cpp
+++ b/tools/designer/src/lib/shared/connectionedit.cpp
@@ -1395,7 +1395,7 @@ void ConnectionEdit::widgetRemoved(QWidget *widget)
if (m_con_list.empty())
return;
- QWidgetList child_list = qFindChildren<QWidget*>(widget);
+ QWidgetList child_list = widget->findChildren<QWidget*>();
child_list.prepend(widget);
const ConnectionSet remove_set = findConnectionsOf(m_con_list, child_list.constBegin(), child_list.constEnd());
@@ -1545,7 +1545,7 @@ void ConnectionEdit::setSource(Connection *con, const QString &obj_name)
{
QObject *object = 0;
if (!obj_name.isEmpty()) {
- object = qFindChild<QObject*>(m_bg_widget, obj_name);
+ object = m_bg_widget->findChild<QObject*>(obj_name);
if (object == 0 && m_bg_widget->objectName() == obj_name)
object = m_bg_widget;
@@ -1559,7 +1559,7 @@ void ConnectionEdit::setTarget(Connection *con, const QString &obj_name)
{
QObject *object = 0;
if (!obj_name.isEmpty()) {
- object = qFindChild<QObject*>(m_bg_widget, obj_name);
+ object = m_bg_widget->findChild<QObject*>(obj_name);
if (object == 0 && m_bg_widget->objectName() == obj_name)
object = m_bg_widget;
diff --git a/tools/designer/src/lib/shared/formlayoutmenu.cpp b/tools/designer/src/lib/shared/formlayoutmenu.cpp
index 544b721..d52bb53 100644
--- a/tools/designer/src/lib/shared/formlayoutmenu.cpp
+++ b/tools/designer/src/lib/shared/formlayoutmenu.cpp
@@ -432,16 +432,16 @@ static QPair<QWidget *,QWidget *>
const QString objectNameProperty = QLatin1String("objectName");
QDesignerPropertySheetExtension *labelSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.first);
int nameIndex = labelSheet->indexOf(objectNameProperty);
- labelSheet->setProperty(nameIndex, qVariantFromValue(PropertySheetStringValue(row.labelName)));
+ labelSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.labelName)));
labelSheet->setChanged(nameIndex, true);
formWindow->ensureUniqueObjectName(rc.first);
const int textIndex = labelSheet->indexOf(QLatin1String("text"));
- labelSheet->setProperty(textIndex, qVariantFromValue(PropertySheetStringValue(row.labelText)));
+ labelSheet->setProperty(textIndex, QVariant::fromValue(PropertySheetStringValue(row.labelText)));
labelSheet->setChanged(textIndex, true);
// Set up properties of the control
QDesignerPropertySheetExtension *controlSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.second);
nameIndex = controlSheet->indexOf(objectNameProperty);
- controlSheet->setProperty(nameIndex, qVariantFromValue(PropertySheetStringValue(row.fieldName)));
+ controlSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.fieldName)));
controlSheet->setChanged(nameIndex, true);
formWindow->ensureUniqueObjectName(rc.second);
return rc;
diff --git a/tools/designer/src/lib/shared/formwindowbase.cpp b/tools/designer/src/lib/shared/formwindowbase.cpp
index ba34805..7c87eaf 100644
--- a/tools/designer/src/lib/shared/formwindowbase.cpp
+++ b/tools/designer/src/lib/shared/formwindowbase.cpp
@@ -184,11 +184,11 @@ void FormWindowBase::reloadProperties()
const int index = itIndex.next().key();
const QVariant newValue = sheet->property(index);
if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) {
- const PropertySheetStringValue newString = qVariantValue<PropertySheetStringValue>(newValue);
+ const PropertySheetStringValue newString = qvariant_cast<PropertySheetStringValue>(newValue);
// optimize a bit, reset only if the text value might contain a reference to qt resources
// (however reloading of icons other than taken from resources might not work here)
if (newString.value().contains(QLatin1String(":/"))) {
- const QVariant resetValue = qVariantFromValue(PropertySheetStringValue());
+ const QVariant resetValue = QVariant::fromValue(PropertySheetStringValue());
sheet->setProperty(index, resetValue);
}
}
diff --git a/tools/designer/src/lib/shared/grid.cpp b/tools/designer/src/lib/shared/grid.cpp
index 57ee2f7..ba991c7 100644
--- a/tools/designer/src/lib/shared/grid.cpp
+++ b/tools/designer/src/lib/shared/grid.cpp
@@ -71,7 +71,7 @@ template <class T>
const QVariantMap::const_iterator it = v.constFind(key);
const bool found = it != v.constEnd();
if (found)
- value = qVariantValue<T>(it.value());
+ value = qvariant_cast<T>(it.value());
return found;
}
@@ -89,12 +89,20 @@ Grid::Grid() :
bool Grid::fromVariantMap(const QVariantMap& vm)
{
- *this = Grid();
- valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), m_visible);
- valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), m_snapX);
- valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), m_snapY);
- valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), m_deltaX);
- return valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), m_deltaY);
+ Grid grid;
+ bool anyData = valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), grid.m_visible);
+ anyData |= valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), grid.m_snapX);
+ anyData |= valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), grid.m_snapY);
+ anyData |= valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), grid.m_deltaX);
+ anyData |= valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), grid.m_deltaY);
+ if (!anyData)
+ return false;
+ if (grid.m_deltaX == 0 || grid.m_deltaY == 0) {
+ qWarning("Attempt to set invalid grid with a spacing of 0.");
+ return false;
+ }
+ *this = grid;
+ return true;
}
QVariantMap Grid::toVariantMap(bool forceKeys) const
diff --git a/tools/designer/src/lib/shared/iconselector.cpp b/tools/designer/src/lib/shared/iconselector.cpp
index 9248129..0d6e3e0 100644
--- a/tools/designer/src/lib/shared/iconselector.cpp
+++ b/tools/designer/src/lib/shared/iconselector.cpp
@@ -67,8 +67,12 @@
#include <QtGui/QImageReader>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QVBoxLayout>
+#include <QtGui/QLineEdit>
+#include <QtGui/QLabel>
+#include <QtGui/QValidator>
#include <QtCore/QDebug>
+
QT_BEGIN_NAMESPACE
namespace qdesigner_internal {
@@ -181,6 +185,14 @@ LanguageResourceDialog* LanguageResourceDialog::create(QDesignerFormEditorInterf
}
// ------------ IconSelectorPrivate
+
+static inline QPixmap emptyPixmap()
+{
+ QImage img(16, 16, QImage::Format_ARGB32_Premultiplied);
+ img.fill(0);
+ return QPixmap::fromImage(img);
+}
+
class IconSelectorPrivate
{
IconSelector *q_ptr;
@@ -201,7 +213,7 @@ public:
QMap<QPair<QIcon::Mode, QIcon::State>, int> m_stateToIndex;
QMap<int, QPair<QIcon::Mode, QIcon::State> > m_indexToState;
- QIcon m_emptyIcon;
+ const QIcon m_emptyIcon;
QComboBox *m_stateComboBox;
QToolButton *m_iconButton;
QAction *m_resetAction;
@@ -215,6 +227,7 @@ public:
IconSelectorPrivate::IconSelectorPrivate() :
q_ptr(0),
+ m_emptyIcon(emptyPixmap()),
m_stateComboBox(0),
m_iconButton(0),
m_resetAction(0),
@@ -449,10 +462,6 @@ IconSelector::IconSelector(QWidget *parent) :
d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Selected, QIcon::Off), tr("Selected Off") );
d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Selected, QIcon::On), tr("Selected On") );
- QImage img(16, 16, QImage::Format_ARGB32_Premultiplied);
- img.fill(0);
- d_ptr->m_emptyIcon = QIcon(QPixmap::fromImage(img));
-
QMenu *setMenu = new QMenu(this);
QAction *setResourceAction = new QAction(tr("Choose Resource..."), this);
@@ -535,9 +544,112 @@ void IconSelector::setPixmapCache(DesignerPixmapCache *pixmapCache)
d_ptr->slotUpdate();
}
+// --- IconThemeEditor
+
+// Validator for theme line edit, accepts empty or non-blank strings.
+class BlankSuppressingValidator : public QValidator {
+public:
+ explicit BlankSuppressingValidator(QObject * parent = 0) : QValidator(parent) {}
+
+ virtual State validate(QString &input, int &pos) const {
+ const int blankPos = input.indexOf(QLatin1Char(' '));
+ if (blankPos != -1) {
+ pos = blankPos;
+ return Invalid;
+ }
+ return Acceptable;
+ }
+};
+
+struct IconThemeEditorPrivate {
+ IconThemeEditorPrivate();
+
+ const QPixmap m_emptyPixmap;
+ QLineEdit *m_themeLineEdit;
+ QLabel *m_themeLabel;
+};
+
+IconThemeEditorPrivate::IconThemeEditorPrivate() :
+ m_emptyPixmap(emptyPixmap()),
+ m_themeLineEdit(new QLineEdit),
+ m_themeLabel(new QLabel)
+{
+}
+
+IconThemeEditor::IconThemeEditor(QWidget *parent, bool wantResetButton) :
+ QWidget (parent), d(new IconThemeEditorPrivate)
+{
+ QHBoxLayout *mainHLayout = new QHBoxLayout;
+ mainHLayout->setMargin(0);
+
+ // Vertically center theme preview label
+ d->m_themeLabel->setPixmap(d->m_emptyPixmap);
+
+ QVBoxLayout *themeLabelVLayout = new QVBoxLayout;
+ d->m_themeLabel->setMargin(1);
+ themeLabelVLayout->setMargin(0);
+ themeLabelVLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
+ themeLabelVLayout->addWidget(d->m_themeLabel);
+ themeLabelVLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
+ mainHLayout->addLayout(themeLabelVLayout);
+
+ d->m_themeLineEdit = new QLineEdit;
+ d->m_themeLineEdit->setValidator(new BlankSuppressingValidator(d->m_themeLineEdit));
+ connect(d->m_themeLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotChanged(QString)));
+ connect(d->m_themeLineEdit, SIGNAL(textEdited(QString)), this, SIGNAL(edited(QString)));
+ mainHLayout->addWidget(d->m_themeLineEdit);
+
+ if (wantResetButton) {
+ QToolButton *themeResetButton = new QToolButton;
+ themeResetButton->setIcon(createIconSet(QLatin1String("resetproperty.png")));
+ connect(themeResetButton, SIGNAL(clicked()), this, SLOT(reset()));
+ mainHLayout->addWidget(themeResetButton);
+ }
+
+ setLayout(mainHLayout);
+ setFocusProxy(d->m_themeLineEdit);
+}
+
+IconThemeEditor::~IconThemeEditor()
+{
+}
+
+void IconThemeEditor::reset()
+{
+ d->m_themeLineEdit->clear();
+ emit edited(QString());
+}
+
+void IconThemeEditor::slotChanged(const QString &theme)
+{
+ updatePreview(theme);
+}
+
+void IconThemeEditor::updatePreview(const QString &t)
+{
+ // Update preview label with icon.
+ if (t.isEmpty() || !QIcon::hasThemeIcon(t)) { // Empty
+ const QPixmap *currentPixmap = d->m_themeLabel->pixmap();
+ if (currentPixmap == 0 || currentPixmap->serialNumber() != d->m_emptyPixmap.serialNumber())
+ d->m_themeLabel->setPixmap(d->m_emptyPixmap);
+ } else {
+ const QIcon icon = QIcon::fromTheme(t);
+ d->m_themeLabel->setPixmap(icon.pixmap(d->m_emptyPixmap.size()));
+ }
+}
+
+QString IconThemeEditor::theme() const
+{
+ return d->m_themeLineEdit->text();
+}
+
+void IconThemeEditor::setTheme(const QString &t)
+{
+ d->m_themeLineEdit->setText(t);
+}
+
} // qdesigner_internal
QT_END_NAMESPACE
#include "moc_iconselector_p.cpp"
-
diff --git a/tools/designer/src/lib/shared/iconselector_p.h b/tools/designer/src/lib/shared/iconselector_p.h
index 50ad938..4f68b73 100644
--- a/tools/designer/src/lib/shared/iconselector_p.h
+++ b/tools/designer/src/lib/shared/iconselector_p.h
@@ -55,9 +55,12 @@
#define ICONSELECTOR_H
#include "shared_global_p.h"
+
#include <QtGui/QWidget>
#include <QtGui/QDialog>
+#include <QtCore/QScopedPointer>
+
QT_BEGIN_NAMESPACE
class QtResourceModel;
@@ -70,6 +73,7 @@ namespace qdesigner_internal {
class DesignerIconCache;
class DesignerPixmapCache;
class PropertySheetIconValue;
+struct IconThemeEditorPrivate;
// Resource Dialog that embeds the language-dependent resource widget as returned by the language extension
class QDESIGNER_SHARED_EXPORT LanguageResourceDialog : public QDialog
@@ -133,6 +137,32 @@ private:
Q_PRIVATE_SLOT(d_func(), void slotUpdate())
};
+// IconThemeEditor: Let's the user input theme icon names and shows a preview label.
+class QDESIGNER_SHARED_EXPORT IconThemeEditor : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString theme READ theme WRITE setTheme DESIGNABLE true)
+public:
+ explicit IconThemeEditor(QWidget *parent = 0, bool wantResetButton = true);
+ virtual ~IconThemeEditor();
+
+ QString theme() const;
+ void setTheme(const QString &theme);
+
+signals:
+ void edited(const QString &);
+
+public slots:
+ void reset();
+
+private slots:
+ void slotChanged(const QString &);
+
+private:
+ void updatePreview(const QString &);
+
+ QScopedPointer<IconThemeEditorPrivate> d;
+};
} // namespace qdesigner_internal
diff --git a/tools/designer/src/lib/shared/layoutinfo.cpp b/tools/designer/src/lib/shared/layoutinfo.cpp
index 8f2d509..804d069 100644
--- a/tools/designer/src/lib/shared/layoutinfo.cpp
+++ b/tools/designer/src/lib/shared/layoutinfo.cpp
@@ -190,7 +190,7 @@ LayoutInfo::Type LayoutInfo::laidoutWidgetType(const QDesignerFormEditorInterfac
}
// 3) Some child layout (see below comment about Q3GroupBox)
- const QList<QLayout*> childLayouts = qFindChildren<QLayout*>(parentLayout);
+ const QList<QLayout*> childLayouts = parentLayout->findChildren<QLayout*>();
if (childLayouts.empty())
return NoLayout;
const QList<QLayout*>::const_iterator lcend = childLayouts.constEnd();
@@ -244,7 +244,7 @@ QLayout *LayoutInfo::managedLayout(const QDesignerFormEditorInterface *core, QLa
* widget->layout() returns an internal VBoxLayout. */
const QDesignerMetaDataBaseItemInterface *item = metaDataBase->item(layout);
if (item == 0) {
- layout = qFindChild<QLayout*>(layout);
+ layout = layout->findChild<QLayout*>();
item = metaDataBase->item(layout);
}
if (!item)
diff --git a/tools/designer/src/lib/shared/morphmenu.cpp b/tools/designer/src/lib/shared/morphmenu.cpp
index e4c5b81..67121e5 100644
--- a/tools/designer/src/lib/shared/morphmenu.cpp
+++ b/tools/designer/src/lib/shared/morphmenu.cpp
@@ -193,7 +193,7 @@ static QStringList classesOfCategory(MorphCategory cat)
<< QLatin1String("QSpinBox") << QLatin1String("QDoubleSpinBox");
break;
case MorphTextEdit:
- l << QLatin1String("QTextEdit") << QLatin1String("QPlainTextEdit");
+ l << QLatin1String("QTextEdit") << QLatin1String("QPlainTextEdit") << QLatin1String("QTextBrowser");
break;
}
}
@@ -240,7 +240,7 @@ static QString suggestObjectName(const QString &oldClassName, const QString &new
QLabel *buddyLabelOf(QDesignerFormWindowInterface *fw, QWidget *w)
{
typedef QList<QLabel*> LabelList;
- const LabelList labelList = qFindChildren<QLabel*>(fw);
+ const LabelList labelList = fw->findChildren<QLabel*>();
if (labelList.empty())
return 0;
const LabelList::const_iterator cend = labelList.constEnd();
@@ -256,11 +256,11 @@ static void replaceWidgetListDynamicProperty(QWidget *parentWidget,
QWidget *oldWidget, QWidget *newWidget,
const char *name)
{
- QWidgetList list = qVariantValue<QWidgetList>(parentWidget->property(name));
+ QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property(name));
const int index = list.indexOf(oldWidget);
if (index != -1) {
list.replace(index, newWidget);
- parentWidget->setProperty(name, qVariantFromValue(list));
+ parentWidget->setProperty(name, QVariant::fromValue(list));
}
}
diff --git a/tools/designer/src/lib/shared/newactiondialog.cpp b/tools/designer/src/lib/shared/newactiondialog.cpp
index d4444ab..9aaa347 100644
--- a/tools/designer/src/lib/shared/newactiondialog.cpp
+++ b/tools/designer/src/lib/shared/newactiondialog.cpp
@@ -133,6 +133,7 @@ ActionData NewActionDialog::actionData() const
rc.name = actionName();
rc.toolTip = m_ui->tooltipEditor->text();
rc.icon = m_ui->iconSelector->icon();
+ rc.icon.setTheme(m_ui->iconThemeEditor->theme());
rc.checkable = m_ui->checkableCheckBox->checkState() == Qt::Checked;
rc.keysequence = PropertySheetKeySequenceValue(m_ui->keySequenceEdit->keySequence());
return rc;
@@ -142,7 +143,8 @@ void NewActionDialog::setActionData(const ActionData &d)
{
m_ui->editActionText->setText(d.text);
m_ui->editObjectName->setText(d.name);
- m_ui->iconSelector->setIcon(d.icon);
+ m_ui->iconSelector->setIcon(d.icon.unthemed());
+ m_ui->iconThemeEditor->setTheme(d.icon.theme());
m_ui->tooltipEditor->setText(d.toolTip);
m_ui->keySequenceEdit->setKeySequence(d.keysequence.value());
m_ui->checkableCheckBox->setCheckState(d.checkable ? Qt::Checked : Qt::Unchecked);
diff --git a/tools/designer/src/lib/shared/newactiondialog.ui b/tools/designer/src/lib/shared/newactiondialog.ui
index ed210a7..17b5d64 100644
--- a/tools/designer/src/lib/shared/newactiondialog.ui
+++ b/tools/designer/src/lib/shared/newactiondialog.ui
@@ -42,6 +42,14 @@
*********************************************************************</comment>
<class>qdesigner_internal::NewActionDialog</class>
<widget class="QDialog" name="qdesigner_internal::NewActionDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>366</width>
+ <height>270</height>
+ </rect>
+ </property>
<property name="windowTitle">
<string>New Action...</string>
</property>
@@ -81,7 +89,7 @@
<item row="1" column="1">
<widget class="QLineEdit" name="editObjectName"/>
</item>
- <item row="3" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="iconLabel">
<property name="text">
<string>&amp;Icon:</string>
@@ -91,7 +99,7 @@
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="qdesigner_internal::IconSelector" name="iconSelector" native="true"/>
@@ -111,31 +119,40 @@
</item>
</layout>
</item>
- <item row="5" column="0">
+ <item row="6" column="0">
<widget class="QLabel" name="shortcutLabel">
<property name="text">
- <string>Shortcut:</string>
+ <string>&amp;Shortcut:</string>
+ </property>
+ <property name="buddy">
+ <cstring>keySequenceEdit</cstring>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<widget class="QCheckBox" name="checkableCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="checkableLabel">
<property name="text">
- <string>Checkable:</string>
+ <string>&amp;Checkable:</string>
+ </property>
+ <property name="buddy">
+ <cstring>checkableCheckBox</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="toolTipLabel">
<property name="text">
- <string>ToolTip:</string>
+ <string>T&amp;oolTip:</string>
+ </property>
+ <property name="buddy">
+ <cstring>tooltipEditor</cstring>
</property>
</widget>
</item>
@@ -160,7 +177,7 @@
</item>
</layout>
</item>
- <item row="5" column="1">
+ <item row="6" column="1">
<layout class="QHBoxLayout" name="keysequenceLayout">
<item>
<widget class="QtKeySequenceEdit" name="keySequenceEdit" native="true">
@@ -181,6 +198,19 @@
</item>
</layout>
</item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="iconThemeLabel">
+ <property name="text">
+ <string>Icon th&amp;eme:</string>
+ </property>
+ <property name="buddy">
+ <cstring>iconThemeEditor</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="qdesigner_internal::IconThemeEditor" name="iconThemeEditor" native="true"/>
+ </item>
</layout>
</item>
<item>
@@ -234,6 +264,12 @@
<header>textpropertyeditor_p.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>qdesigner_internal::IconThemeEditor</class>
+ <extends>QWidget</extends>
+ <header>iconselector_p.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<tabstops>
<tabstop>editActionText</tabstop>
diff --git a/tools/designer/src/lib/shared/qdesigner_command.cpp b/tools/designer/src/lib/shared/qdesigner_command.cpp
index 295c94a..148b4c8 100644
--- a/tools/designer/src/lib/shared/qdesigner_command.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_command.cpp
@@ -107,23 +107,23 @@ static const char *zOrderPropertyC = "_q_zOrder";
static void addToWidgetListDynamicProperty(QWidget *parentWidget, QWidget *widget, const char *name, int index = -1)
{
- QWidgetList list = qVariantValue<QWidgetList>(parentWidget->property(name));
+ QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property(name));
list.removeAll(widget);
if (index >= 0 && index < list.size()) {
list.insert(index, widget);
} else {
list.append(widget);
}
- parentWidget->setProperty(name, qVariantFromValue(list));
+ parentWidget->setProperty(name, QVariant::fromValue(list));
}
static int removeFromWidgetListDynamicProperty(QWidget *parentWidget, QWidget *widget, const char *name)
{
- QWidgetList list = qVariantValue<QWidgetList>(parentWidget->property(name));
+ QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property(name));
const int firstIndex = list.indexOf(widget);
if (firstIndex != -1) {
list.removeAll(widget);
- parentWidget->setProperty(name, qVariantFromValue(list));
+ parentWidget->setProperty(name, QVariant::fromValue(list));
}
return firstIndex;
}
@@ -247,7 +247,7 @@ void InsertWidgetCommand::refreshBuddyLabels()
{
typedef QList<QLabel*> LabelList;
- const LabelList label_list = qFindChildren<QLabel*>(formWindow());
+ const LabelList label_list = formWindow()->findChildren<QLabel*>();
if (label_list.empty())
return;
@@ -281,7 +281,7 @@ void ChangeZOrderCommand::init(QWidget *widget)
setText(QApplication::translate("Command", "Change Z-order of '%1'").arg(widget->objectName()));
- m_oldParentZOrder = qVariantValue<QWidgetList>(widget->parentWidget()->property("_q_zOrder"));
+ m_oldParentZOrder = qvariant_cast<QWidgetList>(widget->parentWidget()->property("_q_zOrder"));
const int index = m_oldParentZOrder.indexOf(m_widget);
if (index != -1 && index + 1 < m_oldParentZOrder.count())
m_oldPreceding = m_oldParentZOrder.at(index + 1);
@@ -289,14 +289,14 @@ void ChangeZOrderCommand::init(QWidget *widget)
void ChangeZOrderCommand::redo()
{
- m_widget->parentWidget()->setProperty("_q_zOrder", qVariantFromValue(reorderWidget(m_oldParentZOrder, m_widget)));
+ m_widget->parentWidget()->setProperty("_q_zOrder", QVariant::fromValue(reorderWidget(m_oldParentZOrder, m_widget)));
reorder(m_widget);
}
void ChangeZOrderCommand::undo()
{
- m_widget->parentWidget()->setProperty("_q_zOrder", qVariantFromValue(m_oldParentZOrder));
+ m_widget->parentWidget()->setProperty("_q_zOrder", QVariant::fromValue(m_oldParentZOrder));
if (m_oldPreceding)
m_widget->stackUnder(m_oldPreceding);
@@ -365,7 +365,7 @@ void ManageWidgetCommandHelper::init(const QDesignerFormWindowInterface *fw, QWi
m_widget = widget;
m_managedChildren.clear();
- const QWidgetList children = qFindChildren<QWidget *>(m_widget);
+ const QWidgetList children = m_widget->findChildren<QWidget *>();
if (children.empty())
return;
@@ -580,8 +580,8 @@ void ReparentWidgetCommand::init(QWidget *widget, QWidget *parentWidget)
setText(QApplication::translate("Command", "Reparent '%1'").arg(widget->objectName()));
- m_oldParentList = qVariantValue<QWidgetList>(m_oldParentWidget->property("_q_widgetOrder"));
- m_oldParentZOrder = qVariantValue<QWidgetList>(m_oldParentWidget->property("_q_zOrder"));
+ m_oldParentList = qvariant_cast<QWidgetList>(m_oldParentWidget->property("_q_widgetOrder"));
+ m_oldParentZOrder = qvariant_cast<QWidgetList>(m_oldParentWidget->property("_q_zOrder"));
}
void ReparentWidgetCommand::redo()
@@ -591,19 +591,19 @@ void ReparentWidgetCommand::redo()
QWidgetList oldList = m_oldParentList;
oldList.removeAll(m_widget);
- m_oldParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(oldList));
+ m_oldParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(oldList));
- QWidgetList newList = qVariantValue<QWidgetList>(m_newParentWidget->property("_q_widgetOrder"));
+ QWidgetList newList = qvariant_cast<QWidgetList>(m_newParentWidget->property("_q_widgetOrder"));
newList.append(m_widget);
- m_newParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(newList));
+ m_newParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(newList));
QWidgetList oldZOrder = m_oldParentZOrder;
oldZOrder.removeAll(m_widget);
- m_oldParentWidget->setProperty("_q_zOrder", qVariantFromValue(oldZOrder));
+ m_oldParentWidget->setProperty("_q_zOrder", QVariant::fromValue(oldZOrder));
- QWidgetList newZOrder = qVariantValue<QWidgetList>(m_newParentWidget->property("_q_zOrder"));
+ QWidgetList newZOrder = qvariant_cast<QWidgetList>(m_newParentWidget->property("_q_zOrder"));
newZOrder.append(m_widget);
- m_newParentWidget->setProperty("_q_zOrder", qVariantFromValue(newZOrder));
+ m_newParentWidget->setProperty("_q_zOrder", QVariant::fromValue(newZOrder));
m_widget->show();
core()->objectInspector()->setFormWindow(formWindow());
@@ -614,16 +614,16 @@ void ReparentWidgetCommand::undo()
m_widget->setParent(m_oldParentWidget);
m_widget->move(m_oldPos);
- m_oldParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(m_oldParentList));
+ m_oldParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(m_oldParentList));
- QWidgetList newList = qVariantValue<QWidgetList>(m_newParentWidget->property("_q_widgetOrder"));
+ QWidgetList newList = qvariant_cast<QWidgetList>(m_newParentWidget->property("_q_widgetOrder"));
newList.removeAll(m_widget);
- m_newParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(newList));
+ m_newParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(newList));
- m_oldParentWidget->setProperty("_q_zOrder", qVariantFromValue(m_oldParentZOrder));
+ m_oldParentWidget->setProperty("_q_zOrder", QVariant::fromValue(m_oldParentZOrder));
- QWidgetList newZOrder = qVariantValue<QWidgetList>(m_newParentWidget->property("_q_zOrder"));
- m_newParentWidget->setProperty("_q_zOrder", qVariantFromValue(newZOrder));
+ QWidgetList newZOrder = qvariant_cast<QWidgetList>(m_newParentWidget->property("_q_zOrder"));
+ m_newParentWidget->setProperty("_q_zOrder", QVariant::fromValue(newZOrder));
m_widget->show();
core()->objectInspector()->setFormWindow(formWindow());
@@ -1016,7 +1016,7 @@ void ToolBoxCommand::addPage()
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), m_toolBox);
if (sheet) {
qdesigner_internal::PropertySheetStringValue itemText(m_itemText);
- sheet->setProperty(sheet->indexOf(QLatin1String("currentItemText")), qVariantFromValue(itemText));
+ sheet->setProperty(sheet->indexOf(QLatin1String("currentItemText")), QVariant::fromValue(itemText));
}
m_widget->show();
@@ -1176,7 +1176,7 @@ void TabWidgetCommand::addPage()
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), m_tabWidget);
if (sheet) {
qdesigner_internal::PropertySheetStringValue itemText(m_itemText);
- sheet->setProperty(sheet->indexOf(QLatin1String("currentTabText")), qVariantFromValue(itemText));
+ sheet->setProperty(sheet->indexOf(QLatin1String("currentTabText")), QVariant::fromValue(itemText));
}
formWindow()->clearSelection();
@@ -2193,7 +2193,7 @@ static void copyRolesFromItem(ItemData *id, const T *item, bool editor)
if (editor)
copyRoleFromItem<T>(id, ItemFlagsShadowRole, item);
else if (item->flags() != defaultFlags)
- id->m_properties.insert(ItemFlagsShadowRole, qVariantFromValue((int)item->flags()));
+ id->m_properties.insert(ItemFlagsShadowRole, QVariant::fromValue((int)item->flags()));
}
template<class T>
@@ -2210,19 +2210,19 @@ static void copyRolesToItem(const ItemData *id, T *item, DesignerIconCache *icon
switch (it.key()) {
case Qt::DecorationPropertyRole:
if (iconCache)
- item->setIcon(iconCache->icon(qVariantValue<PropertySheetIconValue>(it.value())));
+ item->setIcon(iconCache->icon(qvariant_cast<PropertySheetIconValue>(it.value())));
break;
case Qt::DisplayPropertyRole:
- item->setText(qVariantValue<PropertySheetStringValue>(it.value()).value());
+ item->setText(qvariant_cast<PropertySheetStringValue>(it.value()).value());
break;
case Qt::ToolTipPropertyRole:
- item->setToolTip(qVariantValue<PropertySheetStringValue>(it.value()).value());
+ item->setToolTip(qvariant_cast<PropertySheetStringValue>(it.value()).value());
break;
case Qt::StatusTipPropertyRole:
- item->setStatusTip(qVariantValue<PropertySheetStringValue>(it.value()).value());
+ item->setStatusTip(qvariant_cast<PropertySheetStringValue>(it.value()).value());
break;
case Qt::WhatsThisPropertyRole:
- item->setWhatsThis(qVariantValue<PropertySheetStringValue>(it.value()).value());
+ item->setWhatsThis(qvariant_cast<PropertySheetStringValue>(it.value()).value());
break;
}
}
@@ -2267,7 +2267,7 @@ ItemData::ItemData(const QTreeWidgetItem *item, int column)
{
copyRoleFromItem(this, Qt::EditRole, item, column);
PropertySheetStringValue str(item->text(column));
- m_properties.insert(Qt::DisplayPropertyRole, qVariantFromValue(str));
+ m_properties.insert(Qt::DisplayPropertyRole, QVariant::fromValue(str));
for (int i = 0; itemRoles[i] != -1; i++)
copyRoleFromItem(this, itemRoles[i], item, column);
@@ -2282,19 +2282,19 @@ void ItemData::fillTreeItemColumn(QTreeWidgetItem *item, int column, DesignerIco
switch (it.key()) {
case Qt::DecorationPropertyRole:
if (iconCache)
- item->setIcon(column, iconCache->icon(qVariantValue<PropertySheetIconValue>(it.value())));
+ item->setIcon(column, iconCache->icon(qvariant_cast<PropertySheetIconValue>(it.value())));
break;
case Qt::DisplayPropertyRole:
- item->setText(column, qVariantValue<PropertySheetStringValue>(it.value()).value());
+ item->setText(column, qvariant_cast<PropertySheetStringValue>(it.value()).value());
break;
case Qt::ToolTipPropertyRole:
- item->setToolTip(column, qVariantValue<PropertySheetStringValue>(it.value()).value());
+ item->setToolTip(column, qvariant_cast<PropertySheetStringValue>(it.value()).value());
break;
case Qt::StatusTipPropertyRole:
- item->setStatusTip(column, qVariantValue<PropertySheetStringValue>(it.value()).value());
+ item->setStatusTip(column, qvariant_cast<PropertySheetStringValue>(it.value()).value());
break;
case Qt::WhatsThisPropertyRole:
- item->setWhatsThis(column, qVariantValue<PropertySheetStringValue>(it.value()).value());
+ item->setWhatsThis(column, qvariant_cast<PropertySheetStringValue>(it.value()).value());
break;
}
}
@@ -2364,10 +2364,10 @@ void ListContents::applyToComboBox(QComboBox *comboBox, DesignerIconCache *iconC
foreach (const ItemData &hash, m_items) {
QIcon icon;
if (iconCache)
- icon = iconCache->icon(qVariantValue<PropertySheetIconValue>(
+ icon = iconCache->icon(qvariant_cast<PropertySheetIconValue>(
hash.m_properties[Qt::DecorationPropertyRole]));
QVariant var = hash.m_properties[Qt::DisplayPropertyRole];
- PropertySheetStringValue str = qVariantValue<PropertySheetStringValue>(var);
+ PropertySheetStringValue str = qvariant_cast<PropertySheetStringValue>(var);
comboBox->addItem(icon, str.value());
comboBox->setItemData(comboBox->count() - 1,
var,
@@ -2407,7 +2407,7 @@ bool TableWidgetContents::nonEmpty(const QTableWidgetItem *item, int headerColum
if (item->flags() != defaultFlags)
return true;
- QString text = qVariantValue<PropertySheetStringValue>(item->data(Qt::DisplayPropertyRole)).value();
+ QString text = qvariant_cast<PropertySheetStringValue>(item->data(Qt::DisplayPropertyRole)).value();
if (!text.isEmpty()) {
if (headerColumn < 0 || text != defaultHeaderText(headerColumn))
return true;
@@ -2545,7 +2545,7 @@ QTreeWidgetItem *TreeWidgetContents::ItemContents::createTreeItem(DesignerIconCa
if (m_itemFlags != -1) {
if (editor)
- item->setData(0, ItemFlagsShadowRole, qVariantFromValue(m_itemFlags));
+ item->setData(0, ItemFlagsShadowRole, QVariant::fromValue(m_itemFlags));
else
item->setFlags((Qt::ItemFlags)m_itemFlags);
}
diff --git a/tools/designer/src/lib/shared/qdesigner_command2.cpp b/tools/designer/src/lib/shared/qdesigner_command2.cpp
index 6667eff..2b0a5a2 100644
--- a/tools/designer/src/lib/shared/qdesigner_command2.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_command2.cpp
@@ -154,6 +154,68 @@ QString MorphLayoutCommand::formatDescription(QDesignerFormEditorInterface * /*
return QApplication::translate("Command", "Change layout of '%1' from %2 to %3").arg(widgetName, oldName, newName);
}
+LayoutAlignmentCommand::LayoutAlignmentCommand(QDesignerFormWindowInterface *formWindow) :
+ QDesignerFormWindowCommand(QApplication::translate("Command", "Change layout alignment"), formWindow),
+ m_newAlignment(0), m_oldAlignment(0), m_widget(0)
+{
+}
+
+bool LayoutAlignmentCommand::init(QWidget *w, Qt::Alignment alignment)
+{
+ bool enabled;
+ m_newAlignment = alignment;
+ m_oldAlignment = LayoutAlignmentCommand::alignmentOf(core(), w, &enabled);
+ m_widget = w;
+ return enabled;
+}
+
+void LayoutAlignmentCommand::redo()
+{
+ LayoutAlignmentCommand::applyAlignment(core(), m_widget, m_newAlignment);
+}
+
+void LayoutAlignmentCommand::undo()
+{
+ LayoutAlignmentCommand::applyAlignment(core(), m_widget, m_oldAlignment);
+}
+
+// Find out alignment and return whether command is enabled.
+Qt::Alignment LayoutAlignmentCommand::alignmentOf(const QDesignerFormEditorInterface *core, QWidget *w, bool *enabledIn)
+{
+ bool managed;
+ QLayout *layout;
+
+ if (enabledIn)
+ *enabledIn = false;
+ // Can only work on a managed layout
+ const LayoutInfo::Type type = LayoutInfo::laidoutWidgetType(core, w, &managed, &layout);
+ const bool enabled = layout && managed &&
+ (type == LayoutInfo::HBox || type == LayoutInfo::VBox
+ || type == LayoutInfo::Grid);
+ if (!enabled)
+ return Qt::Alignment(0);
+ // Get alignment
+ const int index = layout->indexOf(w);
+ Q_ASSERT(index >= 0);
+ if (enabledIn)
+ *enabledIn = true;
+ return layout->itemAt(index)->alignment();
+}
+
+void LayoutAlignmentCommand::applyAlignment(const QDesignerFormEditorInterface *core, QWidget *w, Qt::Alignment a)
+{
+ // Find layout and apply to item
+ QLayout *layout;
+ LayoutInfo::laidoutWidgetType(core, w, 0, &layout);
+ if (layout) {
+ const int index = layout->indexOf(w);
+ if (index >= 0) {
+ layout->itemAt(index)->setAlignment(a);
+ layout->update();
+ }
+ }
+}
+
} // namespace qdesigner_internal
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/shared/qdesigner_command2_p.h b/tools/designer/src/lib/shared/qdesigner_command2_p.h
index eb9fef7..0a6cce8 100644
--- a/tools/designer/src/lib/shared/qdesigner_command2_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_command2_p.h
@@ -94,6 +94,28 @@ private:
QWidget *m_layoutBase;
};
+// Change the alignment of a widget in a managed grid/box layout cell.
+class LayoutAlignmentCommand : public QDesignerFormWindowCommand {
+ Q_DISABLE_COPY(LayoutAlignmentCommand)
+public:
+ explicit LayoutAlignmentCommand(QDesignerFormWindowInterface *formWindow);
+
+ bool init(QWidget *w, Qt::Alignment alignment);
+
+ virtual void redo();
+ virtual void undo();
+
+ // Find out alignment and return whether command is enabled.
+ static Qt::Alignment alignmentOf(const QDesignerFormEditorInterface *core, QWidget *w, bool *enabled = 0);
+
+private:
+ static void applyAlignment(const QDesignerFormEditorInterface *core, QWidget *w, Qt::Alignment a);
+
+ Qt::Alignment m_newAlignment;
+ Qt::Alignment m_oldAlignment;
+ QWidget *m_widget;
+};
+
} // namespace qdesigner_internal
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp b/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp
index 478a240..a805474 100644
--- a/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp
@@ -243,7 +243,7 @@ static bool readDomEnumerationValue(const DomProperty *p,
if (index == -1)
return false;
const QVariant sheetValue = sheet->property(index);
- if (qVariantCanConvert<PropertySheetFlagValue>(sheetValue)) {
+ if (sheetValue.canConvert<PropertySheetFlagValue>()) {
const PropertySheetFlagValue f = qvariant_cast<PropertySheetFlagValue>(sheetValue);
bool ok = false;
v = f.metaFlags.parseFlags(p->elementSet(), &ok);
@@ -258,7 +258,7 @@ static bool readDomEnumerationValue(const DomProperty *p,
if (index == -1)
return false;
const QVariant sheetValue = sheet->property(index);
- if (qVariantCanConvert<PropertySheetEnumValue>(sheetValue)) {
+ if (sheetValue.canConvert<PropertySheetEnumValue>()) {
const PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(sheetValue);
bool ok = false;
v = e.metaEnum.parseEnum(p->elementEnum(), &ok);
diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
index cac79ef..3efc829 100644
--- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
@@ -115,7 +115,7 @@ void QDesignerFormWindowCommand::updateBuddies(QDesignerFormWindowInterface *for
typedef QList<QLabel*> LabelList;
- const LabelList label_list = qFindChildren<QLabel*>(form);
+ const LabelList label_list = form->findChildren<QLabel*>();
if (label_list.empty())
return;
diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp
index cab00ec..e9abf30 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp
@@ -477,7 +477,7 @@ bool QDesignerMenu::handleContextMenuEvent(QWidget *, QContextMenuEvent *event)
QMenu menu;
QVariant itemData;
- qVariantSetValue(itemData, action);
+ itemData.setValue(action);
QAction *addSeparatorAction = menu.addAction(tr("Insert separator"));
addSeparatorAction->setData(itemData);
@@ -630,7 +630,7 @@ QDesignerMenu *QDesignerMenu::findActivatedMenu() const
{
QList<QDesignerMenu*> candidates;
candidates.append(const_cast<QDesignerMenu*>(this));
- candidates += qFindChildren<QDesignerMenu*>(this);
+ candidates += findChildren<QDesignerMenu*>();
foreach (QDesignerMenu *m, candidates) {
if (m == qApp->activeWindow())
@@ -867,7 +867,7 @@ void QDesignerMenu::closeMenuChain()
w = w->parentWidget();
if (w) {
- foreach (QMenu *subMenu, qFindChildren<QMenu*>(w)) {
+ foreach (QMenu *subMenu, w->findChildren<QMenu*>()) {
subMenu->hide();
}
}
@@ -1323,7 +1323,7 @@ QAction *QDesignerMenu::safeActionAt(int index) const
void QDesignerMenu::hideSubMenu()
{
m_lastSubMenuIndex = -1;
- foreach (QMenu *subMenu, qFindChildren<QMenu*>(this)) {
+ foreach (QMenu *subMenu, findChildren<QMenu*>()) {
subMenu->hide();
}
}
diff --git a/tools/designer/src/lib/shared/qdesigner_menubar.cpp b/tools/designer/src/lib/shared/qdesigner_menubar.cpp
index 3424b49..534cf0c 100644
--- a/tools/designer/src/lib/shared/qdesigner_menubar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menubar.cpp
@@ -403,7 +403,7 @@ ActionList QDesignerMenuBar::contextMenuActions()
if (QAction *action = safeActionAt(m_currentIndex)) {
if (!qobject_cast<SpecialMenuAction*>(action)) {
QVariant itemData;
- qVariantSetValue(itemData, action);
+ itemData.setValue(action);
QAction *remove_action = new QAction(tr("Remove Menu '%1'").arg(action->menu()->objectName()), 0);
remove_action->setData(itemData);
diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
index befe09c..6463016 100644
--- a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
@@ -49,6 +49,7 @@
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtDesigner/QDesignerPromotionInterface>
#include <QtDesigner/QDesignerWidgetDataBaseItemInterface>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <abstractdialoggui_p.h>
#include <QtCore/QTimer>
@@ -152,8 +153,13 @@ namespace qdesigner_internal {
void NewPromotedClassPanel::slotNameChanged(const QString &className) {
// Suggest a name
if (!className.isEmpty()) {
- QString suggestedHeader = className.toLower().replace(QLatin1String("::"), QString(QLatin1Char('_')));
- suggestedHeader += QLatin1String(".h");
+ const QChar dot(QLatin1Char('.'));
+ QString suggestedHeader = m_promotedHeaderLowerCase ?
+ className.toLower() : className;
+ suggestedHeader.replace(QLatin1String("::"), QString(QLatin1Char('_')));
+ if (!m_promotedHeaderSuffix.startsWith(dot))
+ suggestedHeader += dot;
+ suggestedHeader += m_promotedHeaderSuffix;
const bool blocked = m_includeFileEdit->blockSignals(true);
m_includeFileEdit->setText(suggestedHeader);
@@ -248,6 +254,8 @@ namespace qdesigner_internal {
preselectedBaseClass = baseClassNameList.indexOf(QLatin1String("QFrame"));
NewPromotedClassPanel *newPromotedClassPanel = new NewPromotedClassPanel(baseClassNameList, preselectedBaseClass);
+ newPromotedClassPanel->setPromotedHeaderSuffix(core->integration()->headerSuffix());
+ newPromotedClassPanel->setPromotedHeaderLowerCase(core->integration()->isHeaderLowercase());
connect(newPromotedClassPanel, SIGNAL(newPromotedClass(PromotionParameters,bool*)), this, SLOT(slotNewPromotedClass(PromotionParameters,bool*)));
connect(this, SIGNAL(selectedBaseClassChanged(QString)),
newPromotedClassPanel, SLOT(chooseBaseClass(QString)));
diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
index 76d8a5c..73cf7ad 100644
--- a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
@@ -84,7 +84,13 @@ namespace qdesigner_internal {
int selectedBaseClass = -1,
QWidget *parent = 0);
- signals:
+ QString promotedHeaderSuffix() const { return m_promotedHeaderSuffix; }
+ void setPromotedHeaderSuffix(const QString &s) { m_promotedHeaderSuffix = s; }
+
+ bool isPromotedHeaderLowerCase() const { return m_promotedHeaderLowerCase; }
+ void setPromotedHeaderLowerCase(bool l) { m_promotedHeaderLowerCase = l; }
+
+ signals:
void newPromotedClass(const PromotionParameters &, bool *ok);
public slots:
@@ -100,6 +106,9 @@ namespace qdesigner_internal {
PromotionParameters promotionParameters() const;
void enableButtons();
+ QString m_promotedHeaderSuffix;
+ bool m_promotedHeaderLowerCase;
+
QComboBox *m_baseClassCombo;
QLineEdit *m_classNameEdit;
QLineEdit *m_includeFileEdit;
diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
index 01c0206..a9949d8 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
@@ -505,7 +505,7 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant
case QVariant::Size:
return PropertyHelper::Value(applySizeSubProperty(oldValue.toSize(), newValue.toSize(), mask), changed);
case QVariant::SizePolicy:
- return PropertyHelper::Value(qVariantFromValue(applySizePolicySubProperty(qvariant_cast<QSizePolicy>(oldValue), qvariant_cast<QSizePolicy>(newValue), mask)), changed);
+ return PropertyHelper::Value(QVariant::fromValue(applySizePolicySubProperty(qvariant_cast<QSizePolicy>(oldValue), qvariant_cast<QSizePolicy>(newValue), mask)), changed);
case QVariant::Font: {
// Changed flag in case of font and palette depends on resolve mask only, not on the passed "changed" value.
@@ -524,27 +524,27 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant
// He press reset button for the whole font property. In result whole font properties for both
// widgets should be marked as unchanged.
QFont font = applyFontSubProperty(qvariant_cast<QFont>(oldValue), qvariant_cast<QFont>(newValue), mask);
- return PropertyHelper::Value(qVariantFromValue(font), font.resolve());
+ return PropertyHelper::Value(QVariant::fromValue(font), font.resolve());
}
case QVariant::Palette: {
QPalette palette = applyPaletteSubProperty(qvariant_cast<QPalette>(oldValue), qvariant_cast<QPalette>(newValue), mask);
- return PropertyHelper::Value(qVariantFromValue(palette), palette.resolve());
+ return PropertyHelper::Value(QVariant::fromValue(palette), palette.resolve());
}
default:
if (oldValue.userType() == qMetaTypeId<qdesigner_internal::PropertySheetIconValue>()) {
PropertySheetIconValue icon = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(oldValue);
icon.assign(qvariant_cast<qdesigner_internal::PropertySheetIconValue>(newValue), mask);
- return PropertyHelper::Value(qVariantFromValue(icon), icon.mask());
+ return PropertyHelper::Value(QVariant::fromValue(icon), icon.mask());
} else if (oldValue.userType() == qMetaTypeId<qdesigner_internal::PropertySheetStringValue>()) {
qdesigner_internal::PropertySheetStringValue str = applyStringSubProperty(
qvariant_cast<qdesigner_internal::PropertySheetStringValue>(oldValue),
qvariant_cast<qdesigner_internal::PropertySheetStringValue>(newValue), mask);
- return PropertyHelper::Value(qVariantFromValue(str), changed);
+ return PropertyHelper::Value(QVariant::fromValue(str), changed);
} else if (oldValue.userType() == qMetaTypeId<qdesigner_internal::PropertySheetKeySequenceValue>()) {
qdesigner_internal::PropertySheetKeySequenceValue key = applyKeySequenceSubProperty(
qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(oldValue),
qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(newValue), mask);
- return PropertyHelper::Value(qVariantFromValue(key), changed);
+ return PropertyHelper::Value(QVariant::fromValue(key), changed);
}
// Enumerations, flags
switch (specialProperty) {
@@ -552,7 +552,7 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant
qdesigner_internal::PropertySheetFlagValue f = qvariant_cast<qdesigner_internal::PropertySheetFlagValue>(oldValue);
f.value = applyAlignmentSubProperty(variantToAlignment(oldValue), variantToAlignment(newValue), mask);
QVariant v;
- qVariantSetValue(v, f);
+ v.setValue(f);
return PropertyHelper::Value(v, changed);
}
default:
@@ -651,7 +651,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi
switch (specialProperty) {
case SP_MinimumSize: {
const QSize size = checkSize(value.toSize());
- qVariantSetValue(value, size);
+ value.setValue(size);
}
break;
@@ -660,7 +660,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi
checkSizes(fw, value.toSize(), &fs, &cs);
container->setMaximumSize(cs);
fw->mainContainer()->setMaximumSize(fs);
- qVariantSetValue(value, fs);
+ value.setValue(fs);
}
break;
@@ -670,7 +670,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi
checkSizes(fw, r.size(), &fs, &cs);
container->resize(cs);
r.setSize(fs);
- qVariantSetValue(value, r);
+ value.setValue(r);
}
break;
default:
@@ -727,8 +727,8 @@ void PropertyHelper::updateObject(QDesignerFormWindowInterface *fw, const QVaria
case OT_Widget: {
switch (m_specialProperty) {
case SP_ObjectName: {
- const QString oldName = qVariantValue<PropertySheetStringValue>(oldValue).value();
- const QString newName = qVariantValue<PropertySheetStringValue>(newValue).value();
+ const QString oldName = qvariant_cast<PropertySheetStringValue>(oldValue).value();
+ const QString newName = qvariant_cast<PropertySheetStringValue>(newValue).value();
QDesignerFormWindowCommand::updateBuddies(fw, oldName, newName);
}
break;
@@ -751,8 +751,8 @@ void PropertyHelper::updateObject(QDesignerFormWindowInterface *fw, const QVaria
case SP_LayoutName:
case SP_SpacerName:
if (QDesignerIntegration *integr = integration(fw)) {
- const QString oldName = qVariantValue<PropertySheetStringValue>(oldValue).value();
- const QString newName = qVariantValue<PropertySheetStringValue>(newValue).value();
+ const QString oldName = qvariant_cast<PropertySheetStringValue>(oldValue).value();
+ const QString newName = qvariant_cast<PropertySheetStringValue>(newValue).value();
integr->emitObjectNameChanged(fw, m_object, newName, oldName);
}
break;
diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
index 2b2428b..babe20e 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
@@ -290,18 +290,18 @@ bool QDesignerPropertySheetPrivate::isResourceProperty(int index) const
void QDesignerPropertySheetPrivate::addResourceProperty(int index, QVariant::Type type)
{
if (type == QVariant::Pixmap)
- m_resourceProperties.insert(index, qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue()));
+ m_resourceProperties.insert(index, QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue()));
else if (type == QVariant::Icon)
- m_resourceProperties.insert(index, qVariantFromValue(qdesigner_internal::PropertySheetIconValue()));
+ m_resourceProperties.insert(index, QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()));
}
QVariant QDesignerPropertySheetPrivate::emptyResourceProperty(int index) const
{
QVariant v = m_resourceProperties.value(index);
- if (qVariantCanConvert<qdesigner_internal::PropertySheetPixmapValue>(v))
- return qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue());
- if (qVariantCanConvert<qdesigner_internal::PropertySheetIconValue>(v))
- return qVariantFromValue(qdesigner_internal::PropertySheetIconValue());
+ if (v.canConvert<qdesigner_internal::PropertySheetPixmapValue>())
+ return QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue());
+ if (v.canConvert<qdesigner_internal::PropertySheetIconValue>())
+ return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue());
return v;
}
@@ -320,8 +320,8 @@ void QDesignerPropertySheetPrivate::setResourceProperty(int index, const QVarian
Q_ASSERT(isResourceProperty(index));
QVariant &v = m_resourceProperties[index];
- if ((qVariantCanConvert<qdesigner_internal::PropertySheetPixmapValue>(value) && qVariantCanConvert<qdesigner_internal::PropertySheetPixmapValue>(v))
- || (qVariantCanConvert<qdesigner_internal::PropertySheetIconValue>(value) && qVariantCanConvert<qdesigner_internal::PropertySheetIconValue>(v)))
+ if ((value.canConvert<qdesigner_internal::PropertySheetPixmapValue>() && v.canConvert<qdesigner_internal::PropertySheetPixmapValue>())
+ || (value.canConvert<qdesigner_internal::PropertySheetIconValue>() && v.canConvert<qdesigner_internal::PropertySheetIconValue>()))
v = value;
}
@@ -722,14 +722,14 @@ int QDesignerPropertySheet::addDynamicProperty(const QString &propName, const QV
QVariant v = value;
if (value.type() == QVariant::Icon)
- v = qVariantFromValue(qdesigner_internal::PropertySheetIconValue());
+ v = QVariant::fromValue(qdesigner_internal::PropertySheetIconValue());
else if (value.type() == QVariant::Pixmap)
- v = qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue());
+ v = QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue());
else if (value.type() == QVariant::String)
- v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(value.toString()));
+ v = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue(value.toString()));
else if (value.type() == QVariant::KeySequence) {
- const QKeySequence keySequence = qVariantValue<QKeySequence>(value);
- v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
+ const QKeySequence keySequence = qvariant_cast<QKeySequence>(value);
+ v = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
}
if (d->m_addIndex.contains(propName)) {
@@ -873,9 +873,9 @@ int QDesignerPropertySheet::createFakeProperty(const QString &propertyName, cons
info.kind = QDesignerPropertySheetPrivate::FakeProperty;
QVariant v = value.isValid() ? value : metaProperty(index);
if (v.type() == QVariant::String)
- v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue());
+ v = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue());
if (v.type() == QVariant::KeySequence)
- v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue());
+ v = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue());
d->m_fakeProperties.insert(index, v);
return index;
}
@@ -1002,17 +1002,17 @@ QVariant QDesignerPropertySheet::property(int index) const
value.setValue(strValue);
d->setStringProperty(index, value); // cache it
}
- return qVariantFromValue(value);
+ return QVariant::fromValue(value);
}
if (d->isKeySequenceProperty(index)) {
- QKeySequence keyValue = qVariantValue<QKeySequence>(metaProperty(index));
+ QKeySequence keyValue = qvariant_cast<QKeySequence>(metaProperty(index));
qdesigner_internal::PropertySheetKeySequenceValue value = d->keySequenceProperty(index);
if (keyValue != value.value()) {
value.setValue(keyValue);
d->setKeySequenceProperty(index, value); // cache it
}
- return qVariantFromValue(value);
+ return QVariant::fromValue(value);
}
return metaProperty(index);
@@ -1027,12 +1027,12 @@ QVariant QDesignerPropertySheet::metaProperty(int index) const
switch (p->kind()) {
case QDesignerMetaPropertyInterface::FlagKind: {
qdesigner_internal::PropertySheetFlagValue psflags = qdesigner_internal::PropertySheetFlagValue(v.toInt(), designerMetaFlagsFor(p->enumerator()));
- qVariantSetValue(v, psflags);
+ v.setValue(psflags);
}
break;
case QDesignerMetaPropertyInterface::EnumKind: {
qdesigner_internal::PropertySheetEnumValue pse = qdesigner_internal::PropertySheetEnumValue(v.toInt(), designerMetaEnumFor(p->enumerator()));
- qVariantSetValue(v, pse);
+ v.setValue(pse);
}
break;
case QDesignerMetaPropertyInterface::OtherKind:
@@ -1043,20 +1043,20 @@ QVariant QDesignerPropertySheet::metaProperty(int index) const
QVariant QDesignerPropertySheet::resolvePropertyValue(int index, const QVariant &value) const
{
- if (qVariantCanConvert<qdesigner_internal::PropertySheetEnumValue>(value))
+ if (value.canConvert<qdesigner_internal::PropertySheetEnumValue>())
return qvariant_cast<qdesigner_internal::PropertySheetEnumValue>(value).value;
- if (qVariantCanConvert<qdesigner_internal::PropertySheetFlagValue>(value))
+ if (value.canConvert<qdesigner_internal::PropertySheetFlagValue>())
return qvariant_cast<qdesigner_internal::PropertySheetFlagValue>(value).value;
- if (qVariantCanConvert<qdesigner_internal::PropertySheetStringValue>(value))
- return qVariantValue<qdesigner_internal::PropertySheetStringValue>(value).value();
+ if (value.canConvert<qdesigner_internal::PropertySheetStringValue>())
+ return qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value).value();
- if (qVariantCanConvert<qdesigner_internal::PropertySheetKeySequenceValue>(value))
- return qVariantValue<qdesigner_internal::PropertySheetKeySequenceValue>(value).value();
+ if (value.canConvert<qdesigner_internal::PropertySheetKeySequenceValue>())
+ return qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(value).value();
- if (qVariantCanConvert<qdesigner_internal::PropertySheetPixmapValue>(value)) {
- const QString path = qVariantValue<qdesigner_internal::PropertySheetPixmapValue>(value).path();
+ if (value.canConvert<qdesigner_internal::PropertySheetPixmapValue>()) {
+ const QString path = qvariant_cast<qdesigner_internal::PropertySheetPixmapValue>(value).path();
if (path.isEmpty())
return defaultResourceProperty(index);
if (d->m_pixmapCache) {
@@ -1064,9 +1064,9 @@ QVariant QDesignerPropertySheet::resolvePropertyValue(int index, const QVariant
}
}
- if (qVariantCanConvert<qdesigner_internal::PropertySheetIconValue>(value)) {
- const int pathCount = qVariantValue<qdesigner_internal::PropertySheetIconValue>(value).paths().count();
- if (pathCount == 0)
+ if (value.canConvert<qdesigner_internal::PropertySheetIconValue>()) {
+ const unsigned mask = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value).mask();
+ if (mask == 0)
return defaultResourceProperty(index);
if (d->m_iconCache)
return d->m_iconCache->icon(qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value));
@@ -1082,17 +1082,17 @@ void QDesignerPropertySheet::setFakeProperty(int index, const QVariant &value)
QVariant &v = d->m_fakeProperties[index];
// set resource properties also (if we are going to have fake resource properties)
- if (qVariantCanConvert<qdesigner_internal::PropertySheetFlagValue>(value) || qVariantCanConvert<qdesigner_internal::PropertySheetEnumValue>(value)) {
+ if (value.canConvert<qdesigner_internal::PropertySheetFlagValue>() || value.canConvert<qdesigner_internal::PropertySheetEnumValue>()) {
v = value;
- } else if (qVariantCanConvert<qdesigner_internal::PropertySheetFlagValue>(v)) {
+ } else if (v.canConvert<qdesigner_internal::PropertySheetFlagValue>()) {
qdesigner_internal::PropertySheetFlagValue f = qvariant_cast<qdesigner_internal::PropertySheetFlagValue>(v);
f.value = value.toInt();
- qVariantSetValue(v, f);
+ v.setValue(f);
Q_ASSERT(value.type() == QVariant::Int);
- } else if (qVariantCanConvert<qdesigner_internal::PropertySheetEnumValue>(v)) {
+ } else if (v.canConvert<qdesigner_internal::PropertySheetEnumValue>()) {
qdesigner_internal::PropertySheetEnumValue e = qvariant_cast<qdesigner_internal::PropertySheetEnumValue>(v);
e.value = value.toInt();
- qVariantSetValue(v, e);
+ v.setValue(e);
Q_ASSERT(value.type() == QVariant::Int);
} else {
v = value;
@@ -1139,9 +1139,9 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value)
if (d->isResourceProperty(index))
d->setResourceProperty(index, value);
if (d->isStringProperty(index))
- d->setStringProperty(index, qVariantValue<qdesigner_internal::PropertySheetStringValue>(value));
+ d->setStringProperty(index, qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value));
if (d->isKeySequenceProperty(index))
- d->setKeySequenceProperty(index, qVariantValue<qdesigner_internal::PropertySheetKeySequenceValue>(value));
+ d->setKeySequenceProperty(index, qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(value));
d->m_object->setProperty(propertyName(index).toUtf8(), resolvePropertyValue(index, value));
if (d->m_object->isWidgetType()) {
QWidget *w = qobject_cast<QWidget *>(d->m_object);
@@ -1155,26 +1155,26 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value)
if (d->isResourceProperty(index))
d->setResourceProperty(index, value);
if (d->isStringProperty(index))
- d->setStringProperty(index, qVariantValue<qdesigner_internal::PropertySheetStringValue>(value));
+ d->setStringProperty(index, qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value));
if (d->isKeySequenceProperty(index))
- d->setKeySequenceProperty(index, qVariantValue<qdesigner_internal::PropertySheetKeySequenceValue>(value));
+ d->setKeySequenceProperty(index, qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(value));
const QDesignerMetaPropertyInterface *p = d->m_meta->property(index);
p->write(d->m_object, resolvePropertyValue(index, value));
if (qobject_cast<QGroupBox *>(d->m_object) && propertyType(index) == PropertyCheckable) {
const int idx = indexOf(QLatin1String("focusPolicy"));
if (!isChanged(idx)) {
- qdesigner_internal::PropertySheetEnumValue e = qVariantValue<qdesigner_internal::PropertySheetEnumValue>(property(idx));
+ qdesigner_internal::PropertySheetEnumValue e = qvariant_cast<qdesigner_internal::PropertySheetEnumValue>(property(idx));
if (value.toBool()) {
const QDesignerMetaPropertyInterface *p = d->m_meta->property(idx);
p->write(d->m_object, Qt::NoFocus);
e.value = Qt::StrongFocus;
QVariant v;
- qVariantSetValue(v, e);
+ v.setValue(e);
setFakeProperty(idx, v);
} else {
e.value = Qt::NoFocus;
QVariant v;
- qVariantSetValue(v, e);
+ v.setValue(e);
setFakeProperty(idx, v);
}
}
@@ -1196,9 +1196,9 @@ bool QDesignerPropertySheet::reset(int index)
if (d->invalidIndex(Q_FUNC_INFO, index))
return false;
if (d->isStringProperty(index))
- setProperty(index, qVariantFromValue(qdesigner_internal::PropertySheetStringValue()));
+ setProperty(index, QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()));
if (d->isKeySequenceProperty(index))
- setProperty(index, qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue()));
+ setProperty(index, QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue()));
if (d->isResourceProperty(index)) {
setProperty(index, d->emptyResourceProperty(index));
return true;
@@ -1208,10 +1208,10 @@ bool QDesignerPropertySheet::reset(int index)
const QVariant defaultValue = d->m_info.value(index).defaultValue;
QVariant newValue = defaultValue;
if (d->isStringProperty(index)) {
- newValue = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString()));
+ newValue = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString()));
} else if (d->isKeySequenceProperty(index)) {
- const QKeySequence keySequence = qVariantValue<QKeySequence>(newValue);
- newValue = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
+ const QKeySequence keySequence = qvariant_cast<QKeySequence>(newValue);
+ newValue = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
}
if (oldValue == newValue)
return true;
diff --git a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp
index 8fe5f6e..6110dea 100644
--- a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp
@@ -134,7 +134,7 @@ QTabBar *QTabWidgetEventFilter::tabBar() const
{
// QTabWidget::tabBar() accessor is protected, grmbl...
if (!m_cachedTabBar) {
- const QList<QTabBar *> tabBars = qFindChildren<QTabBar *>(m_tabWidget);
+ const QList<QTabBar *> tabBars = m_tabWidget->findChildren<QTabBar *>();
Q_ASSERT(tabBars.size() == 1);
m_cachedTabBar = tabBars.front();
}
@@ -405,13 +405,13 @@ QTabWidgetPropertySheet::QTabWidgetPropertySheet(QTabWidget *object, QObject *pa
QDesignerPropertySheet(object, parent),
m_tabWidget(object)
{
- createFakeProperty(QLatin1String(currentTabTextKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue()));
+ createFakeProperty(QLatin1String(currentTabTextKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()));
createFakeProperty(QLatin1String(currentTabNameKey), QString());
- createFakeProperty(QLatin1String(currentTabIconKey), qVariantFromValue(qdesigner_internal::PropertySheetIconValue()));
+ createFakeProperty(QLatin1String(currentTabIconKey), QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()));
if (formWindowBase())
formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentTabIconKey)));
- createFakeProperty(QLatin1String(currentTabToolTipKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue()));
- createFakeProperty(QLatin1String(currentTabWhatsThisKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue()));
+ createFakeProperty(QLatin1String(currentTabToolTipKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()));
+ createFakeProperty(QLatin1String(currentTabWhatsThisKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()));
// Prevent the tab widget's drag and drop handling from interfering with Designer's
createFakeProperty(QLatin1String(tabMovableKey), QVariant(false));
}
@@ -447,22 +447,22 @@ void QTabWidgetPropertySheet::setProperty(int index, const QVariant &value)
switch (tabWidgetProperty) {
case PropertyCurrentTabText:
m_tabWidget->setTabText(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value)));
- m_pageToData[currentWidget].text = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value);
+ m_pageToData[currentWidget].text = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value);
break;
case PropertyCurrentTabName:
currentWidget->setObjectName(value.toString());
break;
case PropertyCurrentTabIcon:
m_tabWidget->setTabIcon(currentIndex, qvariant_cast<QIcon>(resolvePropertyValue(index, value)));
- m_pageToData[currentWidget].icon = qVariantValue<qdesigner_internal::PropertySheetIconValue>(value);
+ m_pageToData[currentWidget].icon = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value);
break;
case PropertyCurrentTabToolTip:
m_tabWidget->setTabToolTip(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value)));
- m_pageToData[currentWidget].tooltip = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value);
+ m_pageToData[currentWidget].tooltip = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value);
break;
case PropertyCurrentTabWhatsThis:
m_tabWidget->setTabWhatsThis(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value)));
- m_pageToData[currentWidget].whatsthis = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value);
+ m_pageToData[currentWidget].whatsthis = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value);
break;
case PropertyTabWidgetNone:
break;
@@ -486,28 +486,28 @@ QVariant QTabWidgetPropertySheet::property(int index) const
QWidget *currentWidget = m_tabWidget->currentWidget();
if (!currentWidget) {
if (tabWidgetProperty == PropertyCurrentTabIcon)
- return qVariantFromValue(qdesigner_internal::PropertySheetIconValue());
+ return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue());
if (tabWidgetProperty == PropertyCurrentTabText)
- return qVariantFromValue(qdesigner_internal::PropertySheetStringValue());
+ return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue());
if (tabWidgetProperty == PropertyCurrentTabToolTip)
- return qVariantFromValue(qdesigner_internal::PropertySheetStringValue());
+ return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue());
if (tabWidgetProperty == PropertyCurrentTabWhatsThis)
- return qVariantFromValue(qdesigner_internal::PropertySheetStringValue());
+ return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue());
return QVariant(QString());
}
// index-dependent
switch (tabWidgetProperty) {
case PropertyCurrentTabText:
- return qVariantFromValue(m_pageToData.value(currentWidget).text);
+ return QVariant::fromValue(m_pageToData.value(currentWidget).text);
case PropertyCurrentTabName:
return currentWidget->objectName();
case PropertyCurrentTabIcon:
- return qVariantFromValue(m_pageToData.value(currentWidget).icon);
+ return QVariant::fromValue(m_pageToData.value(currentWidget).icon);
case PropertyCurrentTabToolTip:
- return qVariantFromValue(m_pageToData.value(currentWidget).tooltip);
+ return QVariant::fromValue(m_pageToData.value(currentWidget).tooltip);
case PropertyCurrentTabWhatsThis:
- return qVariantFromValue(m_pageToData.value(currentWidget).whatsthis);
+ return QVariant::fromValue(m_pageToData.value(currentWidget).whatsthis);
case PropertyTabWidgetNone:
break;
}
diff --git a/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp b/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp
index 0e89f90..5a9ace4 100644
--- a/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp
@@ -41,6 +41,7 @@
#include "qdesigner_taskmenu_p.h"
#include "qdesigner_command_p.h"
+#include "qdesigner_command2_p.h"
#include "richtexteditor_p.h"
#include "plaintexteditor_p.h"
#include "stylesheeteditor_p.h"
@@ -132,7 +133,7 @@ static QString objName(const QDesignerFormEditorInterface *core, QObject *object
const QString objectNameProperty = QLatin1String("objectName");
const int index = sheet->indexOf(objectNameProperty);
const qdesigner_internal::PropertySheetStringValue objectNameValue
- = qVariantValue<qdesigner_internal::PropertySheetStringValue>(sheet->property(index));
+ = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(sheet->property(index));
return objectNameValue.value();
}
@@ -180,10 +181,128 @@ QString ObjectNameDialog::newObjectName() const
{
return m_editor->text();
}
+} // namespace
+namespace qdesigner_internal {
+
+// Sub menu displaying the alignment options of a widget in a managed
+// grid/box layout cell.
+class LayoutAlignmentMenu {
+public:
+ explicit LayoutAlignmentMenu(QObject *parent);
+
+ QAction *subMenuAction() const { return m_subMenuAction; }
+
+ void connect(QObject *receiver, const char *aSlot);
+
+ // Set up enabled state and checked actions according to widget (managed box/grid)
+ bool setAlignment(const QDesignerFormEditorInterface *core, QWidget *w);
+
+ // Return the currently checked alignment
+ Qt::Alignment alignment() const;
+
+private:
+ enum Actions { HorizNone, Left, HorizCenter, Right, VerticalNone, Top, VerticalCenter, Bottom };
+ static QAction *createAction(const QString &text, int data, QMenu *menu, QActionGroup *ag);
+
+ QAction *m_subMenuAction;
+ QActionGroup *m_horizGroup;
+ QActionGroup *m_verticalGroup;
+ QAction *m_actions[Bottom + 1];
+};
+
+QAction *LayoutAlignmentMenu::createAction(const QString &text, int data, QMenu *menu, QActionGroup *ag)
+{
+ QAction * a = new QAction(text, 0);
+ a->setCheckable(true);
+ a->setData(QVariant(data));
+ menu->addAction(a);
+ ag->addAction(a);
+ return a;
+}
+
+LayoutAlignmentMenu::LayoutAlignmentMenu(QObject *parent) :
+ m_subMenuAction(new QAction(QDesignerTaskMenu::tr("Layout Alignment"), parent)),
+ m_horizGroup(new QActionGroup(parent)),
+ m_verticalGroup(new QActionGroup(parent))
+{
+ m_horizGroup->setExclusive(true);
+ m_verticalGroup->setExclusive(true);
+
+ QMenu *menu = new QMenu;
+ m_subMenuAction->setMenu(menu);
+
+ m_actions[HorizNone] = createAction(QDesignerTaskMenu::tr("No Horizontal Alignment"), 0, menu, m_horizGroup);
+ m_actions[Left] = createAction(QDesignerTaskMenu::tr("Left"), Qt::AlignLeft, menu, m_horizGroup);
+ m_actions[HorizCenter] = createAction(QDesignerTaskMenu::tr("Center Horizontally"), Qt::AlignHCenter, menu, m_horizGroup);
+ m_actions[Right] = createAction(QDesignerTaskMenu::tr("Right"), Qt::AlignRight, menu, m_horizGroup);
+ menu->addSeparator();
+ m_actions[VerticalNone] = createAction(QDesignerTaskMenu::tr("No Vertical Alignment"), 0, menu, m_verticalGroup);
+ m_actions[Top] = createAction(QDesignerTaskMenu::tr("Top"), Qt::AlignTop, menu, m_verticalGroup);
+ m_actions[VerticalCenter] = createAction(QDesignerTaskMenu::tr("Center Vertically"), Qt::AlignVCenter, menu, m_verticalGroup);
+ m_actions[Bottom] = createAction(QDesignerTaskMenu::tr("Bottom"), Qt::AlignBottom, menu, m_verticalGroup);
+}
+
+void LayoutAlignmentMenu::connect(QObject *receiver, const char *aSlot)
+{
+ QObject::connect(m_horizGroup, SIGNAL(triggered(QAction*)), receiver, aSlot);
+ QObject::connect(m_verticalGroup, SIGNAL(triggered(QAction*)), receiver, aSlot);
+}
+
+bool LayoutAlignmentMenu::setAlignment(const QDesignerFormEditorInterface *core, QWidget *w)
+{
+ bool enabled;
+ const Qt::Alignment alignment = LayoutAlignmentCommand::alignmentOf(core, w, &enabled);
+ if (!enabled) {
+ m_subMenuAction->setEnabled(false);
+ m_actions[HorizNone]->setChecked(true);
+ m_actions[VerticalNone]->setChecked(true);
+ return false;
+ }
+ // Get alignment
+ switch (alignment & Qt::AlignHorizontal_Mask) {
+ case Qt::AlignLeft:
+ m_actions[Left]->setChecked(true);
+ break;
+ case Qt::AlignHCenter:
+ m_actions[HorizCenter]->setChecked(true);
+ break;
+ case Qt::AlignRight:
+ m_actions[Right]->setChecked(true);
+ break;
+ default:
+ m_actions[HorizNone]->setChecked(true);
+ break;
+ }
+ switch (alignment & Qt::AlignVertical_Mask) {
+ case Qt::AlignTop:
+ m_actions[Top]->setChecked(true);
+ break;
+ case Qt::AlignVCenter:
+ m_actions[VerticalCenter]->setChecked(true);
+ break;
+ case Qt::AlignBottom:
+ m_actions[Bottom]->setChecked(true);
+ break;
+ default:
+ m_actions[VerticalNone]->setChecked(true);
+ break;
+ }
+ return true;
+}
+
+Qt::Alignment LayoutAlignmentMenu::alignment() const
+{
+ Qt::Alignment alignment = 0;
+ if (const QAction *horizAction = m_horizGroup->checkedAction())
+ if (const int horizAlign = horizAction->data().toInt())
+ alignment |= static_cast<Qt::Alignment>(horizAlign);
+ if (const QAction *vertAction = m_verticalGroup->checkedAction())
+ if (const int vertAlign = vertAction->data().toInt())
+ alignment |= static_cast<Qt::Alignment>(vertAlign);
+ return alignment;
}
-namespace qdesigner_internal {
// -------------- QDesignerTaskMenuPrivate
class QDesignerTaskMenuPrivate {
public:
@@ -214,6 +333,7 @@ public:
QAction *m_navigateToSlot;
PromotionTaskMenu* m_promotionTaskMenu;
QActionGroup *m_sizeActionGroup;
+ LayoutAlignmentMenu m_layoutAlignmentMenu;
QAction *m_sizeActionsSubMenu;
};
@@ -242,6 +362,7 @@ QDesignerTaskMenuPrivate::QDesignerTaskMenuPrivate(QWidget *widget, QObject *par
m_navigateToSlot(new QAction(QDesignerTaskMenu::tr("Go to slot..."), parent)),
m_promotionTaskMenu(new PromotionTaskMenu(widget, PromotionTaskMenu::ModeManagedMultiSelection, parent)),
m_sizeActionGroup(new QActionGroup(parent)),
+ m_layoutAlignmentMenu(parent),
m_sizeActionsSubMenu(new QAction(QDesignerTaskMenu::tr("Size Constraints"), parent))
{
QMenu *sizeMenu = new QMenu;
@@ -293,6 +414,7 @@ QDesignerTaskMenu::QDesignerTaskMenu(QWidget *widget, QObject *parent) :
connect(d->m_containerFakeMethods, SIGNAL(triggered()), this, SLOT(containerFakeMethods()));
connect(d->m_navigateToSlot, SIGNAL(triggered()), this, SLOT(slotNavigateToSlot()));
connect(d->m_sizeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(applySize(QAction*)));
+ d->m_layoutAlignmentMenu.connect(this, SLOT(slotLayoutAlignment()));
}
QDesignerTaskMenu::~QDesignerTaskMenu()
@@ -410,6 +532,9 @@ QList<QAction*> QDesignerTaskMenu::taskActions() const
actions.append(d->m_changeStyleSheet);
actions.append(d->m_separator6);
actions.append(d->m_sizeActionsSubMenu);
+ if (d->m_layoutAlignmentMenu.setAlignment(formWindow->core(), d->m_widget))
+ actions.append(d->m_layoutAlignmentMenu.subMenuAction());
+
d->m_promotionTaskMenu->setMode(formWindow->isManaged(d->m_widget) ?
PromotionTaskMenu::ModeManagedMultiSelection : PromotionTaskMenu::ModeUnmanagedMultiSelection);
d->m_promotionTaskMenu->addActions(formWindow, PromotionTaskMenu::LeadingSeparator, actions);
@@ -447,7 +572,7 @@ void QDesignerTaskMenu::changeObjectName()
const QString objectNameProperty = QLatin1String("objectName");
PropertySheetStringValue objectNameValue;
objectNameValue.setValue(newObjectName);
- setProperty(fw, CurrentWidgetMode, objectNameProperty, qVariantFromValue(objectNameValue));
+ setProperty(fw, CurrentWidgetMode, objectNameProperty, QVariant::fromValue(objectNameValue));
}
}
}
@@ -465,7 +590,7 @@ void QDesignerTaskMenu::changeTextProperty(const QString &propertyName, const QS
qDebug() << "** WARNING Invalid property" << propertyName << " passed to changeTextProperty!";
return;
}
- PropertySheetStringValue textValue = qVariantValue<PropertySheetStringValue>(sheet->property(index));
+ PropertySheetStringValue textValue = qvariant_cast<PropertySheetStringValue>(sheet->property(index));
const QString oldText = textValue.value();
// Pop up respective dialog
bool accepted = false;
@@ -498,7 +623,7 @@ void QDesignerTaskMenu::changeTextProperty(const QString &propertyName, const QS
textValue.setValue(newText);
- setProperty(fw, pm, propertyName, qVariantFromValue(textValue));
+ setProperty(fw, pm, propertyName, QVariant::fromValue(textValue));
}
void QDesignerTaskMenu::changeToolTip()
@@ -673,7 +798,7 @@ void QDesignerTaskMenu::navigateToSlot(QDesignerFormEditorInterface *core,
if (selectSignalDialog.exec() == QDialog::Accepted) {
QTreeWidgetItem *selectedItem = dialogUi.signalList->selectedItems().first();
const QString signalSignature = selectedItem->text(0);
- const QStringList parameterNames = qVariantValue<QStringList>(selectedItem->data(0, Qt::UserRole));
+ const QStringList parameterNames = qvariant_cast<QStringList>(selectedItem->data(0, Qt::UserRole));
// TODO: Check whether signal is connected to slot
integr->emitNavigateToSlot(objectName, signalSignature, parameterNames);
@@ -771,7 +896,17 @@ void QDesignerTaskMenu::setProperty(QDesignerFormWindowInterface *fw, PropertyM
}
}
-
+void QDesignerTaskMenu::slotLayoutAlignment()
+{
+ QDesignerFormWindowInterface *fw = formWindow();
+ const Qt::Alignment newAlignment = d->m_layoutAlignmentMenu.alignment();
+ LayoutAlignmentCommand *cmd = new LayoutAlignmentCommand(fw);
+ if (cmd->init(d->m_widget, newAlignment)) {
+ fw->commandHistory()->push(cmd);
+ } else {
+ delete cmd;
+ }
+}
} // namespace qdesigner_internal
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/shared/qdesigner_taskmenu_p.h b/tools/designer/src/lib/shared/qdesigner_taskmenu_p.h
index a8b3cb8..b86ce69 100644
--- a/tools/designer/src/lib/shared/qdesigner_taskmenu_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_taskmenu_p.h
@@ -118,6 +118,7 @@ private slots:
void containerFakeMethods();
void slotNavigateToSlot();
void applySize(QAction *a);
+ void slotLayoutAlignment();
private:
QDesignerTaskMenuPrivate *d;
diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
index 249228e..0fe7303 100644
--- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
@@ -146,7 +146,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos)
// Insert before
if (action && index != 0 && !action->isSeparator()) {
QAction *newSeperatorAct = new QAction(tr("Insert Separator before '%1'").arg(action->objectName()), 0);
- qVariantSetValue(itemData, action);
+ itemData.setValue(action);
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
rc.push_back(newSeperatorAct);
@@ -155,7 +155,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos)
// Append separator
if (actions.empty() || !actions.back()->isSeparator()) {
QAction *newSeperatorAct = new QAction(tr("Append Separator"), 0);
- qVariantSetValue(itemData, static_cast<QAction*>(0));
+ itemData.setValue(static_cast<QAction*>(0));
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
rc.push_back(newSeperatorAct);
@@ -167,7 +167,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos)
// Remove
if (action) {
QAction *a = new QAction(tr("Remove action '%1'").arg(action->objectName()), 0);
- qVariantSetValue(itemData, action);
+ itemData.setValue(action);
a->setData(itemData);
connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction()));
rc.push_back(a);
diff --git a/tools/designer/src/lib/shared/qdesigner_toolbox.cpp b/tools/designer/src/lib/shared/qdesigner_toolbox.cpp
index bb05af7..675e98c 100644
--- a/tools/designer/src/lib/shared/qdesigner_toolbox.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_toolbox.cpp
@@ -260,12 +260,12 @@ QToolBoxWidgetPropertySheet::QToolBoxWidgetPropertySheet(QToolBox *object, QObje
QDesignerPropertySheet(object, parent),
m_toolBox(object)
{
- createFakeProperty(QLatin1String(currentItemTextKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue()));
+ createFakeProperty(QLatin1String(currentItemTextKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()));
createFakeProperty(QLatin1String(currentItemNameKey), QString());
- createFakeProperty(QLatin1String(currentItemIconKey), qVariantFromValue(qdesigner_internal::PropertySheetIconValue()));
+ createFakeProperty(QLatin1String(currentItemIconKey), QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()));
if (formWindowBase())
formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentItemIconKey)));
- createFakeProperty(QLatin1String(currentItemToolTipKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue()));
+ createFakeProperty(QLatin1String(currentItemToolTipKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()));
createFakeProperty(QLatin1String(tabSpacingKey), QVariant(tabSpacingDefault));
}
@@ -306,18 +306,18 @@ void QToolBoxWidgetPropertySheet::setProperty(int index, const QVariant &value)
switch (toolBoxProperty) {
case PropertyCurrentItemText:
m_toolBox->setItemText(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value)));
- m_pageToData[currentWidget].text = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value);
+ m_pageToData[currentWidget].text = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value);
break;
case PropertyCurrentItemName:
currentWidget->setObjectName(value.toString());
break;
case PropertyCurrentItemIcon:
m_toolBox->setItemIcon(currentIndex, qvariant_cast<QIcon>(resolvePropertyValue(index, value)));
- m_pageToData[currentWidget].icon = qVariantValue<qdesigner_internal::PropertySheetIconValue>(value);
+ m_pageToData[currentWidget].icon = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value);
break;
case PropertyCurrentItemToolTip:
m_toolBox->setItemToolTip(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value)));
- m_pageToData[currentWidget].tooltip = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value);
+ m_pageToData[currentWidget].tooltip = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value);
break;
case PropertyTabSpacing:
case PropertyToolBoxNone:
@@ -353,24 +353,24 @@ QVariant QToolBoxWidgetPropertySheet::property(int index) const
QWidget *currentWidget = m_toolBox->currentWidget();
if (!currentWidget) {
if (toolBoxProperty == PropertyCurrentItemIcon)
- return qVariantFromValue(qdesigner_internal::PropertySheetIconValue());
+ return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue());
if (toolBoxProperty == PropertyCurrentItemText)
- return qVariantFromValue(qdesigner_internal::PropertySheetStringValue());
+ return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue());
if (toolBoxProperty == PropertyCurrentItemToolTip)
- return qVariantFromValue(qdesigner_internal::PropertySheetStringValue());
+ return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue());
return QVariant(QString());
}
// index-dependent
switch (toolBoxProperty) {
case PropertyCurrentItemText:
- return qVariantFromValue(m_pageToData.value(currentWidget).text);
+ return QVariant::fromValue(m_pageToData.value(currentWidget).text);
case PropertyCurrentItemName:
return currentWidget->objectName();
case PropertyCurrentItemIcon:
- return qVariantFromValue(m_pageToData.value(currentWidget).icon);
+ return QVariant::fromValue(m_pageToData.value(currentWidget).icon);
case PropertyCurrentItemToolTip:
- return qVariantFromValue(m_pageToData.value(currentWidget).tooltip);
+ return QVariant::fromValue(m_pageToData.value(currentWidget).tooltip);
case PropertyTabSpacing:
case PropertyToolBoxNone:
break;
diff --git a/tools/designer/src/lib/shared/qdesigner_utils.cpp b/tools/designer/src/lib/shared/qdesigner_utils.cpp
index def6b31..1c6c854 100644
--- a/tools/designer/src/lib/shared/qdesigner_utils.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_utils.cpp
@@ -52,15 +52,16 @@
#include <QtDesigner/QDesignerTaskMenuExtension>
#include <QtDesigner/QExtensionManager>
-#include <QtGui/QIcon>
-#include <QtGui/QPixmap>
#include <QtCore/QDir>
-
-#include <QtGui/QApplication>
#include <QtCore/QProcess>
#include <QtCore/QLibraryInfo>
#include <QtCore/QDebug>
#include <QtCore/QQueue>
+#include <QtCore/QSharedData>
+
+#include <QtGui/QApplication>
+#include <QtGui/QIcon>
+#include <QtGui/QPixmap>
#include <QtGui/QListWidget>
#include <QtGui/QTreeWidget>
#include <QtGui/QTableWidget>
@@ -82,8 +83,8 @@ namespace qdesigner_internal
for (int c = 0; c < item->columnCount(); c++) {
const QVariant v = item->data(c, Qt::DecorationPropertyRole);
- if (qVariantCanConvert<PropertySheetIconValue>(v))
- item->setIcon(c, iconCache->icon(qVariantValue<PropertySheetIconValue>(v)));
+ if (v.canConvert<PropertySheetIconValue>())
+ item->setIcon(c, iconCache->icon(qvariant_cast<PropertySheetIconValue>(v)));
}
}
@@ -93,8 +94,8 @@ namespace qdesigner_internal
return;
const QVariant v = item->data(Qt::DecorationPropertyRole);
- if (qVariantCanConvert<PropertySheetIconValue>(v))
- item->setIcon(iconCache->icon(qVariantValue<PropertySheetIconValue>(v)));
+ if (v.canConvert<PropertySheetIconValue>())
+ item->setIcon(iconCache->icon(qvariant_cast<PropertySheetIconValue>(v)));
}
void reloadTableItem(DesignerIconCache *iconCache, QTableWidgetItem *item)
@@ -103,8 +104,8 @@ namespace qdesigner_internal
return;
const QVariant v = item->data(Qt::DecorationPropertyRole);
- if (qVariantCanConvert<PropertySheetIconValue>(v))
- item->setIcon(iconCache->icon(qVariantValue<PropertySheetIconValue>(v)));
+ if (v.canConvert<PropertySheetIconValue>())
+ item->setIcon(iconCache->icon(qvariant_cast<PropertySheetIconValue>(v)));
}
void reloadIconResources(DesignerIconCache *iconCache, QObject *object)
@@ -115,8 +116,8 @@ namespace qdesigner_internal
} else if (QComboBox *comboBox = qobject_cast<QComboBox *>(object)) {
for (int i = 0; i < comboBox->count(); i++) {
const QVariant v = comboBox->itemData(i, Qt::DecorationPropertyRole);
- if (qVariantCanConvert<PropertySheetIconValue>(v)) {
- QIcon icon = iconCache->icon(qVariantValue<PropertySheetIconValue>(v));
+ if (v.canConvert<PropertySheetIconValue>()) {
+ QIcon icon = iconCache->icon(qvariant_cast<PropertySheetIconValue>(v));
comboBox->setItemIcon(i, icon);
comboBox->setItemData(i, icon);
}
@@ -314,24 +315,51 @@ namespace qdesigner_internal
}
// ---------- PropertySheetIconValue
- PropertySheetIconValue::PropertySheetIconValue(const PropertySheetPixmapValue &pixmap)
+
+ class PropertySheetIconValueData : public QSharedData {
+ public:
+ PropertySheetIconValue::ModeStateToPixmapMap m_paths;
+ QString m_theme;
+ };
+
+ PropertySheetIconValue::PropertySheetIconValue(const PropertySheetPixmapValue &pixmap) :
+ m_data(new PropertySheetIconValueData)
{
setPixmap(QIcon::Normal, QIcon::Off, pixmap);
}
- PropertySheetIconValue::PropertySheetIconValue()
+ PropertySheetIconValue::PropertySheetIconValue() :
+ m_data(new PropertySheetIconValueData)
+ {
+ }
+
+ PropertySheetIconValue::~PropertySheetIconValue()
{
}
+ PropertySheetIconValue::PropertySheetIconValue(const PropertySheetIconValue &rhs) :
+ m_data(rhs.m_data)
+ {
+ }
+
+ PropertySheetIconValue &PropertySheetIconValue::operator=(const PropertySheetIconValue &rhs)
+ {
+ if (this != &rhs)
+ m_data.operator=(rhs.m_data);
+ return *this;
+ }
+
bool PropertySheetIconValue::equals(const PropertySheetIconValue &rhs) const
{
- return m_paths == rhs.m_paths;
+ return m_data->m_theme == rhs.m_data->m_theme && m_data->m_paths == rhs.m_data->m_paths;
}
bool PropertySheetIconValue::operator<(const PropertySheetIconValue &other) const
{
- QMapIterator<ModeStateKey, PropertySheetPixmapValue> itThis(m_paths);
- QMapIterator<ModeStateKey, PropertySheetPixmapValue> itOther(other.m_paths);
+ if (const int themeCmp = m_data->m_theme.compare(other.m_data->m_theme))
+ return themeCmp < 0;
+ QMapIterator<ModeStateKey, PropertySheetPixmapValue> itThis(m_data->m_paths);
+ QMapIterator<ModeStateKey, PropertySheetPixmapValue> itOther(other.m_data->m_paths);
while (itThis.hasNext() && itOther.hasNext()) {
const ModeStateKey thisPair = itThis.next().key();
const ModeStateKey otherPair = itOther.next().key();
@@ -350,19 +378,34 @@ namespace qdesigner_internal
return false;
}
+ bool PropertySheetIconValue::isEmpty() const
+ {
+ return m_data->m_theme.isEmpty() && m_data->m_paths.isEmpty();
+ }
+
+ QString PropertySheetIconValue::theme() const
+ {
+ return m_data->m_theme;
+ }
+
+ void PropertySheetIconValue::setTheme(const QString &t)
+ {
+ m_data->m_theme = t;
+ }
+
PropertySheetPixmapValue PropertySheetIconValue::pixmap(QIcon::Mode mode, QIcon::State state) const
{
const ModeStateKey pair = qMakePair(mode, state);
- return m_paths.value(pair);
+ return m_data->m_paths.value(pair);
}
void PropertySheetIconValue::setPixmap(QIcon::Mode mode, QIcon::State state, const PropertySheetPixmapValue &pixmap)
{
const ModeStateKey pair = qMakePair(mode, state);
if (pixmap.path().isEmpty())
- m_paths.remove(pair);
+ m_data->m_paths.remove(pair);
else
- m_paths.insert(pair, pixmap);
+ m_data->m_paths.insert(pair, pixmap);
}
QPixmap DesignerPixmapCache::pixmap(const PropertySheetPixmapValue &value) const
@@ -388,16 +431,28 @@ namespace qdesigner_internal
QIcon DesignerIconCache::icon(const PropertySheetIconValue &value) const
{
+ typedef PropertySheetIconValue::ModeStateToPixmapMap::const_iterator ModeStateToPixmapMapConstIt;
+
QMap<PropertySheetIconValue, QIcon>::const_iterator it = m_cache.constFind(value);
if (it != m_cache.constEnd())
return it.value();
+ // Match on the theme first if it is available.
+ if (!value.theme().isEmpty()) {
+ const QString theme = value.theme();
+ if (QIcon::hasThemeIcon(theme)) {
+ const QIcon themeIcon = QIcon::fromTheme(theme);
+ m_cache.insert(value, themeIcon);
+ return themeIcon;
+ }
+ }
+
QIcon icon;
- QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> paths = value.paths();
- QMapIterator<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> itPath(paths);
- while (itPath.hasNext()) {
- QPair<QIcon::Mode, QIcon::State> pair = itPath.next().key();
- icon.addFile(itPath.value().path(), QSize(), pair.first, pair.second);
+ const PropertySheetIconValue::ModeStateToPixmapMap &paths = value.paths();
+ const ModeStateToPixmapMapConstIt cend = paths.constEnd();
+ for (ModeStateToPixmapMapConstIt it = paths.constBegin(); it != cend; ++it) {
+ const QPair<QIcon::Mode, QIcon::State> pair = it.key();
+ icon.addFile(it.value().path(), QSize(), pair.first, pair.second);
}
m_cache.insert(value, icon);
return icon;
@@ -547,50 +602,75 @@ namespace qdesigner_internal
&& (m_translatable == rhs.m_translatable) && (m_disambiguation == rhs.m_disambiguation) && (m_comment == rhs.m_comment);
}
- class StateMap
+
+ /* IconSubPropertyMask: Assign each icon sub-property (pixmaps for the
+ * various states/modes and the theme) a flag bit (see QFont) so that they
+ * can be handled individually when assigning property values to
+ * multiselections in the set-property-commands (that is, do not clobber
+ * other subproperties when assigning just one).
+ * Provide back-and-forth mapping functions for the icon states. */
+
+ enum IconSubPropertyMask {
+ NormalOffIconMask = 0x01,
+ NormalOnIconMask = 0x02,
+ DisabledOffIconMask = 0x04,
+ DisabledOnIconMask = 0x08,
+ ActiveOffIconMask = 0x10,
+ ActiveOnIconMask = 0x20,
+ SelectedOffIconMask = 0x40,
+ SelectedOnIconMask = 0x80,
+ ThemeIconMask = 0x10000
+ };
+
+ static inline uint iconStateToSubPropertyFlag(QIcon::Mode mode, QIcon::State state)
{
- public:
- StateMap()
- {
- m_stateToFlag.insert(qMakePair(QIcon::Normal, QIcon::Off), 0x01);
- m_stateToFlag.insert(qMakePair(QIcon::Normal, QIcon::On), 0x02);
- m_stateToFlag.insert(qMakePair(QIcon::Disabled, QIcon::Off), 0x04);
- m_stateToFlag.insert(qMakePair(QIcon::Disabled, QIcon::On), 0x08);
- m_stateToFlag.insert(qMakePair(QIcon::Active, QIcon::Off), 0x10);
- m_stateToFlag.insert(qMakePair(QIcon::Active, QIcon::On), 0x20);
- m_stateToFlag.insert(qMakePair(QIcon::Selected, QIcon::Off), 0x40);
- m_stateToFlag.insert(qMakePair(QIcon::Selected, QIcon::On), 0x80);
-
- m_flagToState.insert(0x01, qMakePair(QIcon::Normal, QIcon::Off));
- m_flagToState.insert(0x02, qMakePair(QIcon::Normal, QIcon::On));
- m_flagToState.insert(0x04, qMakePair(QIcon::Disabled, QIcon::Off));
- m_flagToState.insert(0x08, qMakePair(QIcon::Disabled, QIcon::On));
- m_flagToState.insert(0x10, qMakePair(QIcon::Active, QIcon::Off));
- m_flagToState.insert(0x20, qMakePair(QIcon::Active, QIcon::On));
- m_flagToState.insert(0x40, qMakePair(QIcon::Selected, QIcon::Off));
- m_flagToState.insert(0x80, qMakePair(QIcon::Selected, QIcon::On));
- }
- uint flag(const QPair<QIcon::Mode, QIcon::State> &pair) const
- {
- return m_stateToFlag.value(pair);
+ switch (mode) {
+ case QIcon::Disabled:
+ return state == QIcon::On ? DisabledOnIconMask : DisabledOffIconMask;
+ case QIcon::Active:
+ return state == QIcon::On ? ActiveOnIconMask : ActiveOffIconMask;
+ case QIcon::Selected:
+ return state == QIcon::On ? SelectedOnIconMask : SelectedOffIconMask;
+ case QIcon::Normal:
+ break;
}
- QPair<QIcon::Mode, QIcon::State> state(uint flag) const
- {
- return m_flagToState.value(flag);
+ return state == QIcon::On ? NormalOnIconMask : NormalOffIconMask;
+ }
+
+ static inline QPair<QIcon::Mode, QIcon::State> subPropertyFlagToIconModeState(unsigned flag)
+ {
+ switch (flag) {
+ case NormalOnIconMask:
+ return qMakePair(QIcon::Normal, QIcon::On);
+ case DisabledOffIconMask:
+ return qMakePair(QIcon::Disabled, QIcon::Off);
+ case DisabledOnIconMask:
+ return qMakePair(QIcon::Disabled, QIcon::On);
+ case ActiveOffIconMask:
+ return qMakePair(QIcon::Active, QIcon::Off);
+ case ActiveOnIconMask:
+ return qMakePair(QIcon::Active, QIcon::On);
+ case SelectedOffIconMask:
+ return qMakePair(QIcon::Selected, QIcon::Off);
+ case SelectedOnIconMask:
+ return qMakePair(QIcon::Selected, QIcon::On);
+ case NormalOffIconMask:
+ default:
+ break;
}
- private:
- QMap<QPair<QIcon::Mode, QIcon::State>, uint > m_stateToFlag;
- QMap<uint, QPair<QIcon::Mode, QIcon::State> > m_flagToState;
- };
-
- Q_GLOBAL_STATIC(StateMap, stateMap)
+ return qMakePair(QIcon::Normal, QIcon::Off);
+ }
uint PropertySheetIconValue::mask() const
{
+ typedef ModeStateToPixmapMap::const_iterator ModeStateToPixmapMapConstIt;
+
uint flags = 0;
- QMapIterator<ModeStateKey, PropertySheetPixmapValue> itPath(m_paths);
- while (itPath.hasNext())
- flags |= stateMap()->flag(itPath.next().key());
+ const ModeStateToPixmapMapConstIt cend = m_data->m_paths.constEnd();
+ for (ModeStateToPixmapMapConstIt it = m_data->m_paths.constBegin(); it != cend; ++it)
+ flags |= iconStateToSubPropertyFlag(it.key().first, it.key().second);
+ if (!m_data->m_theme.isEmpty())
+ flags |= ThemeIconMask;
return flags;
}
@@ -598,30 +678,64 @@ namespace qdesigner_internal
{
uint diffMask = mask() | other.mask();
for (int i = 0; i < 8; i++) {
- uint flag = 1 << i;
+ const uint flag = 1 << i;
if (diffMask & flag) { // if state is set in both icons, compare the values
- const ModeStateKey state = stateMap()->state(flag);
+ const QPair<QIcon::Mode, QIcon::State> state = subPropertyFlagToIconModeState(flag);
if (pixmap(state.first, state.second) == other.pixmap(state.first, state.second))
diffMask &= ~flag;
}
}
+ if ((diffMask & ThemeIconMask) && theme() == other.theme())
+ diffMask &= ~ThemeIconMask;
return diffMask;
}
+ PropertySheetIconValue PropertySheetIconValue::themed() const
+ {
+ PropertySheetIconValue rc(*this);
+ rc.m_data->m_paths.clear();
+ return rc;
+ }
+
+ PropertySheetIconValue PropertySheetIconValue::unthemed() const
+ {
+ PropertySheetIconValue rc(*this);
+ rc.m_data->m_theme.clear();
+ return rc;
+ }
+
void PropertySheetIconValue::assign(const PropertySheetIconValue &other, uint mask)
{
for (int i = 0; i < 8; i++) {
uint flag = 1 << i;
if (mask & flag) {
- const ModeStateKey state = stateMap()->state(flag);
+ const ModeStateKey state = subPropertyFlagToIconModeState(flag);
setPixmap(state.first, state.second, other.pixmap(state.first, state.second));
}
}
+ if (mask & ThemeIconMask)
+ setTheme(other.theme());
}
- PropertySheetIconValue::ModeStateToPixmapMap PropertySheetIconValue::paths() const
+ const PropertySheetIconValue::ModeStateToPixmapMap &PropertySheetIconValue::paths() const
{
- return m_paths;
+ return m_data->m_paths;
+ }
+
+ QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug d, const PropertySheetIconValue &p)
+ {
+ typedef PropertySheetIconValue::ModeStateToPixmapMap::const_iterator ModeStateToPixmapMapConstIt;
+
+ QDebug nospace = d.nospace();
+ nospace << "PropertySheetIconValue theme='" << p.theme() << "' ";
+
+ const PropertySheetIconValue::ModeStateToPixmapMap &paths = p.paths();
+ const ModeStateToPixmapMapConstIt cend = paths.constEnd();
+ for (ModeStateToPixmapMapConstIt it = paths.constBegin(); it != cend; ++it)
+ nospace << " mode=" << it.key().first << ",state=" << it.key().second
+ << ",'" << it.value().path() << '\'';
+ nospace << " mask=0x" << QString::number(p.mask(), 16);
+ return d;
}
QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand *createTextPropertyCommand(const QString &propertyName, const QString &text, QObject *object, QDesignerFormWindowInterface *fw)
diff --git a/tools/designer/src/lib/shared/qdesigner_utils_p.h b/tools/designer/src/lib/shared/qdesigner_utils_p.h
index 770dfbc..1e48cf8 100644
--- a/tools/designer/src/lib/shared/qdesigner_utils_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_utils_p.h
@@ -58,6 +58,7 @@
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtCore/QVariant>
+#include <QtCore/QSharedDataPointer>
#include <QtCore/QMap>
#include <QtGui/QMainWindow>
#include <QtGui/QIcon>
@@ -65,6 +66,8 @@
QT_BEGIN_NAMESPACE
+class QDebug;
+
namespace qdesigner_internal {
class QDesignerFormWindowCommand;
class DesignerIconCache;
@@ -252,16 +255,26 @@ private:
// -------------- IconValue: Returned by the property sheet for icons
+class PropertySheetIconValueData;
+
class QDESIGNER_SHARED_EXPORT PropertySheetIconValue
{
public:
PropertySheetIconValue(const PropertySheetPixmapValue &pixmap);
PropertySheetIconValue();
+ ~PropertySheetIconValue();
+ PropertySheetIconValue(const PropertySheetIconValue &);
+ PropertySheetIconValue &operator=(const PropertySheetIconValue &);
bool operator==(const PropertySheetIconValue &other) const { return equals(other); }
bool operator!=(const PropertySheetIconValue &other) const { return !equals(other); }
bool operator<(const PropertySheetIconValue &other) const;
+ bool isEmpty() const;
+
+ QString theme() const;
+ void setTheme(const QString &);
+
PropertySheetPixmapValue pixmap(QIcon::Mode mode, QIcon::State state) const;
void setPixmap(QIcon::Mode mode, QIcon::State state, const PropertySheetPixmapValue &path); // passing the empty path resets the pixmap
@@ -269,17 +282,22 @@ class QDESIGNER_SHARED_EXPORT PropertySheetIconValue
uint compare(const PropertySheetIconValue &other) const;
void assign(const PropertySheetIconValue &other, uint mask);
+ // Convenience accessors to get themed/unthemed icons.
+ PropertySheetIconValue themed() const;
+ PropertySheetIconValue unthemed() const;
+
typedef QPair<QIcon::Mode, QIcon::State> ModeStateKey;
typedef QMap<ModeStateKey, PropertySheetPixmapValue> ModeStateToPixmapMap;
- ModeStateToPixmapMap paths() const;
+ const ModeStateToPixmapMap &paths() const;
private:
bool equals(const PropertySheetIconValue &rhs) const;
-
- ModeStateToPixmapMap m_paths;
+ QSharedDataPointer<PropertySheetIconValueData> m_data;
};
+QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug, const PropertySheetIconValue &);
+
class QDESIGNER_SHARED_EXPORT DesignerPixmapCache : public QObject
{
Q_OBJECT
@@ -432,15 +450,15 @@ namespace Utils {
inline int valueOf(const QVariant &value, bool *ok = 0)
{
- if (qVariantCanConvert<PropertySheetEnumValue>(value)) {
+ if (value.canConvert<PropertySheetEnumValue>()) {
if (ok)
*ok = true;
- return qVariantValue<PropertySheetEnumValue>(value).value;
+ return qvariant_cast<PropertySheetEnumValue>(value).value;
}
- else if (qVariantCanConvert<PropertySheetFlagValue>(value)) {
+ else if (value.canConvert<PropertySheetFlagValue>()) {
if (ok)
*ok = true;
- return qVariantValue<PropertySheetFlagValue>(value).value;
+ return qvariant_cast<PropertySheetFlagValue>(value).value;
}
return value.toInt(ok);
}
diff --git a/tools/designer/src/lib/shared/qlayout_widget.cpp b/tools/designer/src/lib/shared/qlayout_widget.cpp
index 4debb5e..66e7a79 100644
--- a/tools/designer/src/lib/shared/qlayout_widget.cpp
+++ b/tools/designer/src/lib/shared/qlayout_widget.cpp
@@ -601,7 +601,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const
}
}
- // Grid Layout state. Datatypically store the state of a GridLayout as a map of
+ // Grid Layout state. Datatype storing the state of a GridLayout as a map of
// widgets to QRect(columns, rows) and size. Used to store the state for undo operations
// that do not change the widgets within the layout; also provides some manipulation
// functions and ability to apply the state to a layout provided its widgets haven't changed.
@@ -634,7 +634,11 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const
static CellStates cellStates(const QList<QRect> &rects, int numRows, int numColumns);
typedef QMap<QWidget *, QRect> WidgetItemMap;
+ typedef QMap<QWidget *, Qt::Alignment> WidgetAlignmentMap;
+
WidgetItemMap widgetItemMap;
+ WidgetAlignmentMap widgetAlignmentMap;
+
int rowCount;
int colCount;
};
@@ -706,8 +710,11 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const
const int count = l->count();
for (int i = 0; i < count; i++) {
QLayoutItem *item = l->itemAt(i);
- if (!LayoutInfo::isEmptyItem(item))
+ if (!LayoutInfo::isEmptyItem(item)) {
widgetItemMap.insert(item->widget(), gridItemInfo(l, i));
+ if (item->alignment())
+ widgetAlignmentMap.insert(item->widget(), item->alignment());
+ }
}
}
@@ -743,7 +750,8 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const
const LayoutItemRectMap::const_iterator icend = itemMap.constEnd();
for (LayoutItemRectMap::const_iterator it = itemMap.constBegin(); it != icend; ++it) {
const QRect info = it.value();
- grid->addItem(it.key(), info.y(), info.x(), info.height(), info.width());
+ const Qt::Alignment alignment = widgetAlignmentMap.value(it.key()->widget(), Qt::Alignment(0));
+ grid->addItem(it.key(), info.y(), info.x(), info.height(), info.width(), alignment);
}
// create spacers
const CellStates cs = cellStates(itemMap.values(), rowCount, colCount);
diff --git a/tools/designer/src/lib/shared/qtresourcemodel.cpp b/tools/designer/src/lib/shared/qtresourcemodel.cpp
index cf9b1ee..ca2fb78 100644
--- a/tools/designer/src/lib/shared/qtresourcemodel.cpp
+++ b/tools/designer/src/lib/shared/qtresourcemodel.cpp
@@ -184,15 +184,15 @@ const QByteArray *QtResourceModelPrivate::createResource(const QString &path, QS
break;
// return code cannot be fully trusted, might still be empty
const ResourceDataFileMap resMap = library.resourceDataFileMap();
- if (resMap.empty())
- break;
-
if (!library.output(buffer, errorDevice))
break;
*errorCount = library.failedResources().size();
*contents = resMap.keys();
+ if (resMap.empty())
+ break;
+
buffer.close();
rc = new QByteArray(buffer.data());
} while (false);
@@ -225,15 +225,18 @@ void QtResourceModelPrivate::registerResourceSet(QtResourceSet *resourceSet)
qDebug() << "registerResourceSet " << path;
const PathDataMap::const_iterator itRcc = m_pathToData.constFind(path);
if (itRcc != m_pathToData.constEnd()) { // otherwise data was not created yet
- if (!QResource::registerResource(reinterpret_cast<const uchar *>(itRcc.value()->constData()))) {
- qDebug() << "** WARNING: Failed to register " << path << " (QResource failure).";
- } else {
- QStringList contents = m_pathToContents.value(path);
- QStringListIterator itContents(contents);
- while (itContents.hasNext()) {
- const QString filePath = itContents.next();
- if (!m_fileToQrc.contains(filePath)) // the first loaded resource has higher priority in qt resource system
- m_fileToQrc.insert(filePath, path);
+ const QByteArray *data = itRcc.value();
+ if (data) {
+ if (!QResource::registerResource(reinterpret_cast<const uchar *>(data->constData()))) {
+ qWarning() << "** WARNING: Failed to register " << path << " (QResource failure).";
+ } else {
+ QStringList contents = m_pathToContents.value(path);
+ QStringListIterator itContents(contents);
+ while (itContents.hasNext()) {
+ const QString filePath = itContents.next();
+ if (!m_fileToQrc.contains(filePath)) // the first loaded resource has higher priority in qt resource system
+ m_fileToQrc.insert(filePath, path);
+ }
}
}
}
@@ -254,8 +257,11 @@ void QtResourceModelPrivate::unregisterResourceSet(QtResourceSet *resourceSet)
qDebug() << "unregisterResourceSet " << path;
const PathDataMap::const_iterator itRcc = m_pathToData.constFind(path);
if (itRcc != m_pathToData.constEnd()) { // otherwise data was not created yet
- if (!QResource::unregisterResource(reinterpret_cast<const uchar *>(itRcc.value()->constData())))
- qDebug() << "** WARNING: Failed to unregister " << path << " (QResource failure).";
+ const QByteArray *data = itRcc.value();
+ if (data) {
+ if (!QResource::unregisterResource(reinterpret_cast<const uchar *>(itRcc.value()->constData())))
+ qWarning() << "** WARNING: Failed to unregister " << path << " (QResource failure).";
+ }
}
}
m_fileToQrc.clear();
@@ -292,15 +298,13 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL
QStringList contents;
int qrcErrorCount;
generatedCount++;
- if (const QByteArray *data = createResource(path, &contents, &qrcErrorCount, errorStream)) {
- newPathToData.insert(path, data);
- if (qrcErrorCount) // Count single failed files as sort of 1/2 error
- errorCount++;
- addWatcher(path);
- } else {
- newPathToData.remove(path);
+ const QByteArray *data = createResource(path, &contents, &qrcErrorCount, errorStream);
+
+ newPathToData.insert(path, data);
+ if (qrcErrorCount) // Count single failed files as sort of 1/2 error
errorCount++;
- }
+ addWatcher(path);
+
m_pathToModified.insert(path, false);
m_pathToContents.insert(path, contents);
newResourceSetChanged = true;
@@ -326,7 +330,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL
QListIterator<const QByteArray *> itOld(oldData);
if (itOld.hasNext()) {
const QByteArray *array = itOld.next();
- if (!newData.contains(array))
+ if (array && !newData.contains(array))
toDelete.append(array);
}
diff --git a/tools/designer/src/lib/shared/richtexteditor.cpp b/tools/designer/src/lib/shared/richtexteditor.cpp
index 7c87209..c2cdb20 100644
--- a/tools/designer/src/lib/shared/richtexteditor.cpp
+++ b/tools/designer/src/lib/shared/richtexteditor.cpp
@@ -52,6 +52,9 @@
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QPointer>
+#include <QtCore/QXmlStreamReader>
+#include <QtCore/QXmlStreamWriter>
+#include <QtCore/QXmlStreamAttributes>
#include <QtGui/QAction>
#include <QtGui/QColorDialog>
@@ -74,28 +77,129 @@
QT_BEGIN_NAMESPACE
-static const char *RichTextDialogC = "RichTextDialog";
-static const char *Geometry = "Geometry";
+static const char RichTextDialogGroupC[] = "RichTextDialog";
+static const char GeometryKeyC[] = "Geometry";
+static const char TabKeyC[] = "Tab";
+
+const bool simplifyRichTextDefault = true;
namespace qdesigner_internal {
+// Richtext simplification filter helpers: Elements to be discarded
+static inline bool filterElement(const QStringRef &name)
+{
+ return name != QLatin1String("meta") && name != QLatin1String("style");
+}
+
+// Richtext simplification filter helpers: Filter attributes of elements
+static inline void filterAttributes(const QStringRef &name,
+ QXmlStreamAttributes *atts,
+ bool *paragraphAlignmentFound)
+{
+ typedef QXmlStreamAttributes::iterator AttributeIt;
+
+ if (atts->isEmpty())
+ return;
+
+ // No style attributes for <body>
+ if (name == QLatin1String("body")) {
+ atts->clear();
+ return;
+ }
+
+ // Clean out everything except 'align' for 'p'
+ if (name == QLatin1String("p")) {
+ for (AttributeIt it = atts->begin(); it != atts->end(); ) {
+ if (it->name() == QLatin1String("align")) {
+ ++it;
+ *paragraphAlignmentFound = true;
+ } else {
+ it = atts->erase(it);
+ }
+ }
+ return;
+ }
+}
+
+// Richtext simplification filter helpers: Check for blank QStringRef.
+static inline bool isWhiteSpace(const QStringRef &in)
+{
+ const int count = in.size();
+ for (int i = 0; i < count; i++)
+ if (!in.at(i).isSpace())
+ return false;
+ return true;
+}
+
+// Richtext simplification filter: Remove hard-coded font settings,
+// <style> elements, <p> attributes other than 'align' and
+// and unnecessary meta-information.
+QString simplifyRichTextFilter(const QString &in, bool *isPlainTextPtr = 0)
+{
+ unsigned elementCount = 0;
+ bool paragraphAlignmentFound = false;
+ QString out;
+ QXmlStreamReader reader(in);
+ QXmlStreamWriter writer(&out);
+ writer.setAutoFormatting(false);
+ writer.setAutoFormattingIndent(0);
+
+ while (!reader.atEnd()) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement:
+ elementCount++;
+ if (filterElement(reader.name())) {
+ const QStringRef name = reader.name();
+ QXmlStreamAttributes attributes = reader.attributes();
+ filterAttributes(name, &attributes, &paragraphAlignmentFound);
+ writer.writeStartElement(name.toString());
+ if (!attributes.isEmpty())
+ writer.writeAttributes(attributes);
+ } else {
+ reader.readElementText(); // Skip away all nested elements and characters.
+ }
+ break;
+ case QXmlStreamReader::Characters:
+ if (!isWhiteSpace(reader.text()))
+ writer.writeCharacters(reader.text().toString());
+ break;
+ case QXmlStreamReader::EndElement:
+ writer.writeEndElement();
+ break;
+ default:
+ break;
+ }
+ }
+ // Check for plain text (no spans, just <html><head><body><p>)
+ if (isPlainTextPtr)
+ *isPlainTextPtr = !paragraphAlignmentFound && elementCount == 4u; //
+ return out;
+}
+
class RichTextEditor : public QTextEdit
{
Q_OBJECT
public:
- RichTextEditor(QWidget *parent = 0);
- void setDefaultFont(const QFont &font);
+ explicit RichTextEditor(QWidget *parent = 0);
+ void setDefaultFont(QFont font);
QToolBar *createToolBar(QDesignerFormEditorInterface *core, QWidget *parent = 0);
+ bool simplifyRichText() const { return m_simplifyRichText; }
+
public slots:
void setFontBold(bool b);
void setFontPointSize(double);
void setText(const QString &text);
+ void setSimplifyRichText(bool v);
QString text(Qt::TextFormat format) const;
signals:
void stateChanged();
+ void simplifyRichTextChanged(bool);
+
+private:
+ bool m_simplifyRichText;
};
class AddLinkDialog : public QDialog
@@ -303,6 +407,7 @@ private:
QAction *m_align_justify_action;
QAction *m_link_action;
QAction *m_image_action;
+ QAction *m_simplify_richtext_action;
ColorAction *m_color_action;
QComboBox *m_font_size_input;
@@ -432,6 +537,17 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core,
this, SLOT(colorChanged(QColor)));
addAction(m_color_action);
+ addSeparator();
+
+ // Simplify rich text
+ m_simplify_richtext_action
+ = createCheckableAction(createIconSet(QLatin1String("simplifyrichtext.png")),
+ tr("Simplify Rich Text"), m_editor, SLOT(setSimplifyRichText(bool)));
+ m_simplify_richtext_action->setChecked(m_editor->simplifyRichText());
+ connect(m_editor, SIGNAL(simplifyRichTextChanged(bool)),
+ m_simplify_richtext_action, SLOT(setChecked(bool)));
+ addAction(m_simplify_richtext_action);
+
connect(editor, SIGNAL(textChanged()), this, SLOT(updateActions()));
connect(editor, SIGNAL(stateChanged()), this, SLOT(updateActions()));
@@ -551,7 +667,7 @@ void RichTextEditorToolBar::updateActions()
}
RichTextEditor::RichTextEditor(QWidget *parent)
- : QTextEdit(parent)
+ : QTextEdit(parent), m_simplifyRichText(simplifyRichTextDefault)
{
connect(this, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
this, SIGNAL(stateChanged()));
@@ -579,14 +695,31 @@ void RichTextEditor::setFontPointSize(double d)
void RichTextEditor::setText(const QString &text)
{
+
if (Qt::mightBeRichText(text))
setHtml(text);
else
setPlainText(text);
}
-void RichTextEditor::setDefaultFont(const QFont &font)
+void RichTextEditor::setSimplifyRichText(bool v)
{
+ if (v != m_simplifyRichText) {
+ m_simplifyRichText = v;
+ emit simplifyRichTextChanged(v);
+ }
+}
+
+void RichTextEditor::setDefaultFont(QFont font)
+{
+ // Some default fonts on Windows have a default size of 7.8,
+ // which results in complicated rich text generated by toHtml().
+ // Use an integer value.
+ const int pointSize = qRound(font.pointSizeF());
+ if (pointSize > 0 && !qFuzzyCompare(qreal(pointSize), font.pointSizeF())) {
+ font.setPointSize(pointSize);
+ }
+
document()->setDefaultFont(font);
if (font.pointSize() > 0)
setFontPointSize(font.pointSize());
@@ -602,15 +735,16 @@ QString RichTextEditor::text(Qt::TextFormat format) const
case Qt::PlainText:
return toPlainText();
case Qt::RichText:
- return toHtml();
+ return m_simplifyRichText ? simplifyRichTextFilter(toHtml()) : toHtml();
case Qt::AutoText:
break;
}
const QString html = toHtml();
- const QString plain = toPlainText();
- QTextEdit tester;
- tester.setPlainText(plain);
- return tester.toHtml() == html ? plain : html;
+ bool isPlainText;
+ const QString simplifiedHtml = simplifyRichTextFilter(html, &isPlainText);
+ if (isPlainText)
+ return toPlainText();
+ return m_simplifyRichText ? simplifiedHtml : html;
}
RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent) :
@@ -619,15 +753,25 @@ RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, Q
m_text_edit(new HtmlTextEdit),
m_tab_widget(new QTabWidget),
m_state(Clean),
- m_core(core)
+ m_core(core),
+ m_initialTab(RichTextIndex)
{
setWindowTitle(tr("Edit text"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ // Read settings
+ const QDesignerSettingsInterface *settings = core->settingsManager();
+ const QString rootKey = QLatin1String(RichTextDialogGroupC) + QLatin1Char('/');
+ const QByteArray lastGeometry = settings->value(rootKey + QLatin1String(GeometryKeyC)).toByteArray();
+ const int initialTab = settings->value(rootKey + QLatin1String(TabKeyC), QVariant(m_initialTab)).toInt();
+ if (initialTab == RichTextIndex || initialTab == SourceIndex)
+ m_initialTab = initialTab;
+
m_text_edit->setAcceptRichText(false);
new HtmlHighlighter(m_text_edit);
connect(m_editor, SIGNAL(textChanged()), this, SLOT(richTextChanged()));
+ connect(m_editor, SIGNAL(simplifyRichTextChanged(bool)), this, SLOT(richTextChanged()));
connect(m_text_edit, SIGNAL(textChanged()), this, SLOT(sourceChanged()));
// The toolbar needs to be created after the RichTextEditor
@@ -661,32 +805,33 @@ RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, Q
layout->addWidget(m_tab_widget);
layout->addWidget(buttonBox);
- m_editor->setFocus();
-
- QDesignerSettingsInterface *settings = core->settingsManager();
- settings->beginGroup(QLatin1String(RichTextDialogC));
-
- if (settings->contains(QLatin1String(Geometry)))
- restoreGeometry(settings->value(QLatin1String(Geometry)).toByteArray());
-
- settings->endGroup();
+ if (!lastGeometry.isEmpty())
+ restoreGeometry(lastGeometry);
}
RichTextEditorDialog::~RichTextEditorDialog()
{
QDesignerSettingsInterface *settings = m_core->settingsManager();
- settings->beginGroup(QLatin1String(RichTextDialogC));
+ settings->beginGroup(QLatin1String(RichTextDialogGroupC));
- settings->setValue(QLatin1String(Geometry), saveGeometry());
+ settings->setValue(QLatin1String(GeometryKeyC), saveGeometry());
+ settings->setValue(QLatin1String(TabKeyC), m_tab_widget->currentIndex());
settings->endGroup();
}
int RichTextEditorDialog::showDialog()
{
- m_tab_widget->setCurrentIndex(0);
- m_editor->selectAll();
- m_editor->setFocus();
-
+ m_tab_widget->setCurrentIndex(m_initialTab);
+ switch (m_initialTab) {
+ case RichTextIndex:
+ m_editor->selectAll();
+ m_editor->setFocus();
+ break;
+ case SourceIndex:
+ m_text_edit->selectAll();
+ m_text_edit->setFocus();
+ break;
+ }
return exec();
}
@@ -697,6 +842,9 @@ void RichTextEditorDialog::setDefaultFont(const QFont &font)
void RichTextEditorDialog::setText(const QString &text)
{
+ // Generally simplify rich text unless verbose text is found.
+ const bool isSimplifiedRichText = !text.startsWith("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">");
+ m_editor->setSimplifyRichText(isSimplifiedRichText);
m_editor->setText(text);
m_text_edit->setPlainText(text);
m_state = Clean;
diff --git a/tools/designer/src/lib/shared/richtexteditor_p.h b/tools/designer/src/lib/shared/richtexteditor_p.h
index a78db32..086c5d5 100644
--- a/tools/designer/src/lib/shared/richtexteditor_p.h
+++ b/tools/designer/src/lib/shared/richtexteditor_p.h
@@ -93,6 +93,7 @@ private:
QTabWidget *m_tab_widget;
State m_state;
QDesignerFormEditorInterface *m_core;
+ int m_initialTab;
};
} // namespace qdesigner_internal
diff --git a/tools/designer/src/lib/shared/stylesheeteditor.cpp b/tools/designer/src/lib/shared/stylesheeteditor.cpp
index 0c378a7..ee5fea4 100644
--- a/tools/designer/src/lib/shared/stylesheeteditor.cpp
+++ b/tools/designer/src/lib/shared/stylesheeteditor.cpp
@@ -394,14 +394,14 @@ StyleSheetPropertyEditorDialog::StyleSheetPropertyEditorDialog(QWidget *parent,
qt_extension<QDesignerPropertySheetExtension*>(m_fw->core()->extensionManager(), m_widget);
Q_ASSERT(sheet != 0);
const int index = sheet->indexOf(QLatin1String(styleSheetProperty));
- const PropertySheetStringValue value = qVariantValue<PropertySheetStringValue>(sheet->property(index));
+ const PropertySheetStringValue value = qvariant_cast<PropertySheetStringValue>(sheet->property(index));
setText(value.value());
}
void StyleSheetPropertyEditorDialog::applyStyleSheet()
{
const PropertySheetStringValue value(text(), false);
- m_fw->cursor()->setWidgetProperty(m_widget, QLatin1String(styleSheetProperty), qVariantFromValue(value));
+ m_fw->cursor()->setWidgetProperty(m_widget, QLatin1String(styleSheetProperty), QVariant::fromValue(value));
}
} // namespace qdesigner_internal
diff --git a/tools/designer/src/lib/shared/widgetdatabase.cpp b/tools/designer/src/lib/shared/widgetdatabase.cpp
index 6b8fc0d..aa1a775 100644
--- a/tools/designer/src/lib/shared/widgetdatabase.cpp
+++ b/tools/designer/src/lib/shared/widgetdatabase.cpp
@@ -54,7 +54,8 @@
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtXml/QXmlStreamWriter>
-#include <QtCore/QtAlgorithms>
+
+#include <QtCore/QScopedPointer>
#include <QtCore/qdebug.h>
#include <QtCore/QMetaProperty>
#include <QtCore/QTextStream>
@@ -565,10 +566,10 @@ static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const
const bool found = QDesignerWidgetBox::findWidget(core->widgetBox(), className, QString(), &widget);
if (!found)
return QString();
- DomUI *domUI = QDesignerWidgetBox::xmlToUi(className, widget.domXml(), false);
- domUI->setAttributeVersion(QLatin1String("4.0"));
- if (!domUI)
+ QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(className, widget.domXml(), false));
+ if (domUI.isNull())
return QString();
+ domUI->setAttributeVersion(QLatin1String("4.0"));
DomWidget *domWidget = domUI->elementWidget();
if (!domWidget)
return QString();
@@ -615,7 +616,6 @@ static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const
domUI->write(writer);
writer.writeEndDocument();
}
- delete domUI;
return rc;
}
diff --git a/tools/designer/src/lib/shared/widgetfactory.cpp b/tools/designer/src/lib/shared/widgetfactory.cpp
index 36f795e..bcd23ee 100644
--- a/tools/designer/src/lib/shared/widgetfactory.cpp
+++ b/tools/designer/src/lib/shared/widgetfactory.cpp
@@ -784,7 +784,7 @@ void WidgetFactory::applyStyleToTopLevel(QStyle *style, QWidget *widget)
widget->setStyle(style);
widget->setPalette(standardPalette);
- const QWidgetList lst = qFindChildren<QWidget*>(widget);
+ const QWidgetList lst = widget->findChildren<QWidget*>();
const QWidgetList::const_iterator cend = lst.constEnd();
for (QWidgetList::const_iterator it = lst.constBegin(); it != cend; ++it)
(*it)->setStyle(style);
diff --git a/tools/designer/src/lib/shared/zoomwidget.cpp b/tools/designer/src/lib/shared/zoomwidget.cpp
index 57d8f69..c77a518 100644
--- a/tools/designer/src/lib/shared/zoomwidget.cpp
+++ b/tools/designer/src/lib/shared/zoomwidget.cpp
@@ -328,7 +328,7 @@ void ZoomWidget::setWidget(QWidget *w, Qt::WindowFlags wFlags)
scene().removeItem(m_proxy);
if (QWidget *w = m_proxy->widget()) {
// remove the event filter
- if (QObject *evf = qFindChild<QObject*>(w, QLatin1String(zoomedEventFilterRedirectorNameC)))
+ if (QObject *evf = w->findChild<QObject*>(QLatin1String(zoomedEventFilterRedirectorNameC)))
w->removeEventFilter(evf);
}
m_proxy->deleteLater();