summaryrefslogtreecommitdiffstats
path: root/tools/designer/src
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2010-09-28 11:44:45 (GMT)
committerThomas Zander <t.zander@nokia.com>2010-09-28 11:44:45 (GMT)
commit5c08412285f14d89174aef1190a1de1c35fd62bd (patch)
tree2e9bef2fdf0af18db76b011cd9c4ed4b456f507c /tools/designer/src
parent2645784f05db7b1e631621c511e94c88fc5cd211 (diff)
parent2868302626b8a31f44df1068514485a89ec27171 (diff)
downloadQt-5c08412285f14d89174aef1190a1de1c35fd62bd.zip
Qt-5c08412285f14d89174aef1190a1de1c35fd62bd.tar.gz
Qt-5c08412285f14d89174aef1190a1de1c35fd62bd.tar.bz2
Merge commit 'origin/master' into fileEnginesOn47
Conflicts: qmake/Makefile.win32 qmake/qmake.pri src/corelib/io/qdir.cpp src/corelib/io/qfileinfo.cpp src/corelib/io/qfileinfo_p.h src/corelib/io/qfsfileengine_win.cpp src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtCoreu.def src/s60installs/eabi/QtGuiu.def src/tools/bootstrap/bootstrap.pro tests/auto/qfileinfo/tst_qfileinfo.cpp
Diffstat (limited to 'tools/designer/src')
-rw-r--r--tools/designer/src/components/formeditor/formeditor.qrc1
-rw-r--r--tools/designer/src/components/formeditor/formeditor_optionspage.cpp6
-rw-r--r--tools/designer/src/components/formeditor/qdesigner_resource.cpp36
-rw-r--r--tools/designer/src/components/propertyeditor/defs.cpp107
-rw-r--r--tools/designer/src/components/propertyeditor/defs.h60
-rw-r--r--tools/designer/src/components/propertyeditor/designerpropertymanager.cpp310
-rw-r--r--tools/designer/src/components/propertyeditor/designerpropertymanager.h3
-rw-r--r--tools/designer/src/components/propertyeditor/propertyeditor.pri4
-rw-r--r--tools/designer/src/components/taskmenu/itemlisteditor.cpp22
-rw-r--r--tools/designer/src/lib/sdk/abstractintegration.cpp51
-rw-r--r--tools/designer/src/lib/sdk/abstractintegration.h10
-rw-r--r--tools/designer/src/lib/shared/actioneditor.cpp3
-rw-r--r--tools/designer/src/lib/shared/actionrepository.cpp6
-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/newactiondialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/newactiondialog.ui54
-rw-r--r--tools/designer/src/lib/shared/plugindialog.cpp4
-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_propertysheet.cpp4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_utils.cpp232
-rw-r--r--tools/designer/src/lib/shared/qdesigner_utils_p.h24
-rw-r--r--tools/designer/src/lib/uilib/abstractformbuilder.cpp123
-rw-r--r--tools/designer/src/lib/uilib/resourcebuilder.cpp11
-rw-r--r--tools/designer/src/lib/uilib/ui4.cpp11
-rw-r--r--tools/designer/src/lib/uilib/ui4_p.h8
-rw-r--r--tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp4
-rw-r--r--tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp4
-rw-r--r--tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp4
-rw-r--r--tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp4
-rw-r--r--tools/designer/src/plugins/qwebview/qwebview_plugin.cpp4
32 files changed, 908 insertions, 383 deletions
diff --git a/tools/designer/src/components/formeditor/formeditor.qrc b/tools/designer/src/components/formeditor/formeditor.qrc
index ed7e40e..e42cc66 100644
--- a/tools/designer/src/components/formeditor/formeditor.qrc
+++ b/tools/designer/src/components/formeditor/formeditor.qrc
@@ -113,7 +113,6 @@
<file>images/widgets/vslider.png</file>
<file>images/widgets/vspacer.png</file>
<file>images/widgets/widget.png</file>
- <file>images/widgets/widget.png</file>
<file>images/widgets/widgetstack.png</file>
<file>images/widgets/wizard.png</file>
<file>images/win/adjustsize.png</file>
diff --git a/tools/designer/src/components/formeditor/formeditor_optionspage.cpp b/tools/designer/src/components/formeditor/formeditor_optionspage.cpp
index 102f44a..8e0cc66 100644
--- a/tools/designer/src/components/formeditor/formeditor_optionspage.cpp
+++ b/tools/designer/src/components/formeditor/formeditor_optionspage.cpp
@@ -86,9 +86,11 @@ ZoomSettingsWidget::ZoomSettingsWidget(QWidget *parent) :
m_zoomCombo->setEditable(false);
const IntList zoomValues = ZoomMenu::zoomValues();
const IntList::const_iterator cend = zoomValues.constEnd();
- //: Zoom percentage
- for (IntList::const_iterator it = zoomValues.constBegin(); it != cend; ++it)
+
+ for (IntList::const_iterator it = zoomValues.constBegin(); it != cend; ++it) {
+ //: Zoom percentage
m_zoomCombo->addItem(QCoreApplication::translate("FormEditorOptionsPage", "%1 %").arg(*it), QVariant(*it));
+ }
// Layout
setCheckable(true);
diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp
index 6c458f3..7fabf68 100644
--- a/tools/designer/src/components/formeditor/qdesigner_resource.cpp
+++ b/tools/designer/src/components/formeditor/qdesigner_resource.cpp
@@ -171,7 +171,7 @@ QDesignerResourceBuilder::QDesignerResourceBuilder(QDesignerFormEditorInterface
{
}
-static inline void setIconPixmap(QIcon::Mode m, QIcon::State s, const QDir &workingDirectory,
+static inline void setIconPixmap(QIcon::Mode m, QIcon::State s, const QDir &workingDirectory,
QString path, PropertySheetIconValue &icon,
const QDesignerLanguageExtension *lang = 0)
{
@@ -203,6 +203,7 @@ QVariant QDesignerResourceBuilder::loadResource(const QDir &workingDirectory, co
case DomProperty::IconSet: {
PropertySheetIconValue icon;
DomResourceIcon *di = property->elementIconSet();
+ icon.setTheme(di->attributeTheme());
if (const int flags = iconStateFlags(di)) { // new, post 4.4 format
if (flags & NormalOff)
setIconPixmap(QIcon::Normal, QIcon::Off, workingDirectory, di->elementNormalOff()->text(), icon, m_lang);
@@ -278,8 +279,11 @@ DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory
} else if (value.canConvert<PropertySheetIconValue>()) {
const PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(value);
const QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> pixmaps = icon.paths();
- if (!pixmaps.isEmpty()) {
+ const QString theme = icon.theme();
+ if (!pixmaps.isEmpty() || !theme.isEmpty()) {
DomResourceIcon *ri = new DomResourceIcon;
+ if (!theme.isEmpty())
+ ri->setAttributeTheme(theme);
QMapIterator<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> itPix(pixmaps);
while (itPix.hasNext()) {
const QIcon::Mode mode = itPix.next().key().first;
@@ -1377,34 +1381,6 @@ DomLayoutItem *QDesignerResource::createDom(QLayoutItem *item, DomLayout *ui_lay
} else {
return 0;
}
-
- if (m_chain.size() && item->widget()) {
- if (QGridLayout *grid = qobject_cast<QGridLayout*>(m_chain.top())) {
- const int index = Utils::indexOfWidget(grid, item->widget());
-
- int row, column, rowspan, colspan;
- grid->getItemPosition(index, &row, &column, &rowspan, &colspan);
- ui_item->setAttributeRow(row);
- ui_item->setAttributeColumn(column);
-
- if (colspan != 1)
- ui_item->setAttributeColSpan(colspan);
-
- if (rowspan != 1)
- ui_item->setAttributeRowSpan(rowspan);
- } else {
- if (QFormLayout *form = qobject_cast<QFormLayout*>(m_chain.top())) {
- const int index = Utils::indexOfWidget(form, item->widget());
- int row, column, colspan;
- getFormLayoutItemPosition(form, index, &row, &column, 0, &colspan);
- ui_item->setAttributeRow(row);
- ui_item->setAttributeColumn(column);
- if (colspan != 1)
- ui_item->setAttributeColSpan(colspan);
- }
- }
- }
-
return ui_item;
}
diff --git a/tools/designer/src/components/propertyeditor/defs.cpp b/tools/designer/src/components/propertyeditor/defs.cpp
deleted file mode 100644
index 54dec74..0000000
--- a/tools/designer/src/components/propertyeditor/defs.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Designer of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "defs.h"
-
-QT_BEGIN_NAMESPACE
-
-namespace qdesigner_internal {
-
-int size_type_to_int( QSizePolicy::Policy t )
-{
- if ( t == QSizePolicy::Fixed )
- return 0;
- if ( t == QSizePolicy::Minimum )
- return 1;
- if ( t == QSizePolicy::Maximum )
- return 2;
- if ( t == QSizePolicy::Preferred )
- return 3;
- if ( t == QSizePolicy::MinimumExpanding )
- return 4;
- if ( t == QSizePolicy::Expanding )
- return 5;
- if ( t == QSizePolicy::Ignored )
- return 6;
- return 0;
-}
-
-QString size_type_to_string( QSizePolicy::Policy t )
-{
- if ( t == QSizePolicy::Fixed )
- return QString::fromUtf8("Fixed");
- if ( t == QSizePolicy::Minimum )
- return QString::fromUtf8("Minimum");
- if ( t == QSizePolicy::Maximum )
- return QString::fromUtf8("Maximum");
- if ( t == QSizePolicy::Preferred )
- return QString::fromUtf8("Preferred");
- if ( t == QSizePolicy::MinimumExpanding )
- return QString::fromUtf8("MinimumExpanding");
- if ( t == QSizePolicy::Expanding )
- return QString::fromUtf8("Expanding");
- if ( t == QSizePolicy::Ignored )
- return QString::fromUtf8("Ignored");
- return QString();
-}
-
-QSizePolicy::Policy int_to_size_type( int i )
-{
- if ( i == 0 )
- return QSizePolicy::Fixed;
- if ( i == 1 )
- return QSizePolicy::Minimum;
- if ( i == 2 )
- return QSizePolicy::Maximum;
- if ( i == 3 )
- return QSizePolicy::Preferred;
- if ( i == 4 )
- return QSizePolicy::MinimumExpanding;
- if ( i == 5 )
- return QSizePolicy::Expanding;
- if ( i == 6 )
- return QSizePolicy::Ignored;
- return QSizePolicy::Preferred;
-}
-
-} // namespace qdesigner_internal
-
-QT_END_NAMESPACE
diff --git a/tools/designer/src/components/propertyeditor/defs.h b/tools/designer/src/components/propertyeditor/defs.h
deleted file mode 100644
index 28e39fc..0000000
--- a/tools/designer/src/components/propertyeditor/defs.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Designer of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DEFS_H
-#define DEFS_H
-
-#include <QtGui/QSizePolicy>
-#include <QtCore/QString>
-
-QT_BEGIN_NAMESPACE
-
-namespace qdesigner_internal {
-
-int size_type_to_int(QSizePolicy::Policy t);
-QString size_type_to_string(QSizePolicy::Policy t);
-QSizePolicy::Policy int_to_size_type(int i);
-
-} // namespace qdesigner_internal
-
-QT_END_NAMESPACE
-
-#endif // DEFS_H
diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
index e251511..8e7312f 100644
--- a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
+++ b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
@@ -83,6 +83,7 @@ static const char *validationModesAttributeC = "validationMode";
static const char *superPaletteAttributeC = "superPalette";
static const char *defaultResourceAttributeC = "defaultResource";
static const char *fontAttributeC = "font";
+static const char *themeAttributeC = "theme";
class DesignerFlagPropertyType
{
@@ -113,13 +114,15 @@ public:
void setTextPropertyValidationMode(TextPropertyValidationMode vm);
void setRichTextDefaultFont(const QFont &font) { m_richTextDefaultFont = font; }
- QFont richTextDefaultFont() const { return m_richTextDefaultFont; }
+ QFont richTextDefaultFont() const { return m_richTextDefaultFont; }
void setSpacing(int spacing);
TextPropertyEditor::UpdateMode updateMode() const { return m_editor->updateMode(); }
void setUpdateMode(TextPropertyEditor::UpdateMode um) { m_editor->setUpdateMode(um); }
+ void setIconThemeModeEnabled(bool enable);
+
public slots:
void setText(const QString &text);
@@ -132,6 +135,8 @@ private slots:
void fileActionActivated();
private:
TextPropertyEditor *m_editor;
+ IconThemeEditor *m_themeEditor;
+ bool m_iconThemeModeEnabled;
QFont m_richTextDefaultFont;
QToolButton *m_button;
QMenu *m_menu;
@@ -144,6 +149,8 @@ private:
TextEditor::TextEditor(QDesignerFormEditorInterface *core, QWidget *parent) :
QWidget(parent),
m_editor(new TextPropertyEditor(this)),
+ m_themeEditor(new IconThemeEditor(this, false)),
+ m_iconThemeModeEnabled(false),
m_richTextDefaultFont(QApplication::font()),
m_button(new QToolButton(this)),
m_menu(new QMenu(this)),
@@ -152,7 +159,11 @@ TextEditor::TextEditor(QDesignerFormEditorInterface *core, QWidget *parent) :
m_layout(new QHBoxLayout(this)),
m_core(core)
{
+ m_themeEditor->setVisible(false);
+ m_button->setVisible(false);
+
m_layout->addWidget(m_editor);
+ m_layout->addWidget(m_themeEditor);
m_button->setText(tr("..."));
m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
m_button->setFixedWidth(20);
@@ -163,9 +174,10 @@ TextEditor::TextEditor(QDesignerFormEditorInterface *core, QWidget *parent) :
connect(m_resourceAction, SIGNAL(triggered()), this, SLOT(resourceActionActivated()));
connect(m_fileAction, SIGNAL(triggered()), this, SLOT(fileActionActivated()));
connect(m_editor, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString)));
+ connect(m_themeEditor, SIGNAL(edited(QString)), this, SIGNAL(textChanged(QString)));
connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
+
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
- m_button->setVisible(false);
setFocusProxy(m_editor);
m_menu->addAction(m_resourceAction);
@@ -177,6 +189,22 @@ void TextEditor::setSpacing(int spacing)
m_layout->setSpacing(spacing);
}
+void TextEditor::setIconThemeModeEnabled(bool enable)
+{
+ if (m_iconThemeModeEnabled == enable)
+ return; // nothing changes
+ m_iconThemeModeEnabled = enable;
+ m_editor->setVisible(!enable);
+ m_themeEditor->setVisible(enable);
+ if (enable) {
+ m_themeEditor->setTheme(m_editor->text());
+ setFocusProxy(m_themeEditor);
+ } else {
+ m_editor->setText(m_themeEditor->theme());
+ setFocusProxy(m_editor);
+ }
+}
+
TextPropertyValidationMode TextEditor::textPropertyValidationMode() const
{
return m_editor->textPropertyValidationMode();
@@ -199,7 +227,10 @@ void TextEditor::setTextPropertyValidationMode(TextPropertyValidationMode vm)
void TextEditor::setText(const QString &text)
{
- m_editor->setText(text);
+ if (m_iconThemeModeEnabled)
+ m_themeEditor->setTheme(text);
+ else
+ m_editor->setText(text);
}
void TextEditor::buttonClicked()
@@ -279,6 +310,49 @@ void TextEditor::fileActionActivated()
emit textChanged(newText);
}
+// ------------ ThemeInputDialog
+
+class IconThemeDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ static QString getTheme(QWidget *parent, const QString &theme, bool *ok);
+private:
+ IconThemeDialog(QWidget *parent);
+ IconThemeEditor *m_editor;
+};
+
+IconThemeDialog::IconThemeDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setWindowTitle(tr("Set Icon From Theme"));
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ QLabel *label = new QLabel(tr("Input icon name from the current theme:"), this);
+ m_editor = new IconThemeEditor(this);
+ QDialogButtonBox *buttons = new QDialogButtonBox(this);
+ buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+
+ layout->addWidget(label);
+ layout->addWidget(m_editor);
+ layout->addWidget(buttons);
+
+ connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+QString IconThemeDialog::getTheme(QWidget *parent, const QString &theme, bool *ok)
+{
+ IconThemeDialog dlg(parent);
+ dlg.m_editor->setTheme(theme);
+ if (dlg.exec() == QDialog::Accepted) {
+ *ok = true;
+ return dlg.m_editor->theme();
+ }
+ *ok = false;
+ return QString();
+}
+
// ------------ PixmapEditor
class PixmapEditor : public QWidget
{
@@ -288,12 +362,15 @@ public:
void setSpacing(int spacing);
void setPixmapCache(DesignerPixmapCache *cache);
+ void setIconThemeModeEnabled(bool enabled);
public slots:
void setPath(const QString &path);
+ void setTheme(const QString &theme);
void setDefaultPixmap(const QPixmap &pixmap);
signals:
void pathChanged(const QString &path);
+ void themeChanged(const QString &theme);
protected:
void contextMenuEvent(QContextMenuEvent *event);
@@ -302,32 +379,39 @@ private slots:
void defaultActionActivated();
void resourceActionActivated();
void fileActionActivated();
+ void themeActionActivated();
void copyActionActivated();
void pasteActionActivated();
void clipboardDataChanged();
private:
+ void updateLabels();
+ bool m_iconThemeModeEnabled;
QDesignerFormEditorInterface *m_core;
QLabel *m_pixmapLabel;
QLabel *m_pathLabel;
QToolButton *m_button;
QAction *m_resourceAction;
QAction *m_fileAction;
+ QAction *m_themeAction;
QAction *m_copyAction;
QAction *m_pasteAction;
QHBoxLayout *m_layout;
QPixmap m_defaultPixmap;
QString m_path;
+ QString m_theme;
DesignerPixmapCache *m_pixmapCache;
};
PixmapEditor::PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent) :
QWidget(parent),
+ m_iconThemeModeEnabled(false),
m_core(core),
m_pixmapLabel(new QLabel(this)),
m_pathLabel(new QLabel(this)),
m_button(new QToolButton(this)),
m_resourceAction(new QAction(tr("Choose Resource..."), this)),
m_fileAction(new QAction(tr("Choose File..."), this)),
+ m_themeAction(new QAction(tr("Set Icon From Theme..."), this)),
m_copyAction(new QAction(createIconSet(QLatin1String("editcopy.png")), tr("Copy Path"), this)),
m_pasteAction(new QAction(createIconSet(QLatin1String("editpaste.png")), tr("Paste Path"), this)),
m_layout(new QHBoxLayout(this)),
@@ -345,10 +429,12 @@ PixmapEditor::PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent)
m_pixmapLabel->setFixedWidth(16);
m_pixmapLabel->setAlignment(Qt::AlignCenter);
m_pathLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
+ m_themeAction->setVisible(false);
QMenu *menu = new QMenu(this);
menu->addAction(m_resourceAction);
menu->addAction(m_fileAction);
+ menu->addAction(m_themeAction);
m_button->setMenu(menu);
m_button->setText(tr("..."));
@@ -356,6 +442,7 @@ PixmapEditor::PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent)
connect(m_button, SIGNAL(clicked()), this, SLOT(defaultActionActivated()));
connect(m_resourceAction, SIGNAL(triggered()), this, SLOT(resourceActionActivated()));
connect(m_fileAction, SIGNAL(triggered()), this, SLOT(fileActionActivated()));
+ connect(m_themeAction, SIGNAL(triggered()), this, SLOT(themeActionActivated()));
connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copyActionActivated()));
connect(m_pasteAction, SIGNAL(triggered()), this, SLOT(pasteActionActivated()));
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored));
@@ -370,6 +457,14 @@ void PixmapEditor::setPixmapCache(DesignerPixmapCache *cache)
m_pixmapCache = cache;
}
+void PixmapEditor::setIconThemeModeEnabled(bool enabled)
+{
+ if (m_iconThemeModeEnabled == enabled)
+ return;
+ m_iconThemeModeEnabled = enabled;
+ m_themeAction->setVisible(enabled);
+}
+
void PixmapEditor::setSpacing(int spacing)
{
m_layout->setSpacing(spacing);
@@ -378,22 +473,40 @@ void PixmapEditor::setSpacing(int spacing)
void PixmapEditor::setPath(const QString &path)
{
m_path = path;
- if (m_path.isEmpty()) {
- m_pathLabel->setText(path);
- m_pixmapLabel->setPixmap(m_defaultPixmap);
- m_copyAction->setEnabled(false);
- } else {
- m_pathLabel->setText(QFileInfo(m_path).fileName());
- if (m_pixmapCache)
- m_pixmapLabel->setPixmap(QIcon(m_pixmapCache->pixmap(PropertySheetPixmapValue(path))).pixmap(16, 16));
+ updateLabels();
+}
+
+void PixmapEditor::setTheme(const QString &theme)
+{
+ m_theme = theme;
+ updateLabels();
+}
+
+void PixmapEditor::updateLabels()
+{
+ if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(m_theme)) {
+ m_pixmapLabel->setPixmap(QIcon::fromTheme(m_theme).pixmap(16, 16));
+ m_pathLabel->setText(tr("[Theme] %1").arg(m_theme));
m_copyAction->setEnabled(true);
+ } else {
+ if (m_path.isEmpty()) {
+ m_pathLabel->setText(m_path);
+ m_pixmapLabel->setPixmap(m_defaultPixmap);
+ m_copyAction->setEnabled(false);
+ } else {
+ m_pathLabel->setText(QFileInfo(m_path).fileName());
+ if (m_pixmapCache)
+ m_pixmapLabel->setPixmap(QIcon(m_pixmapCache->pixmap(PropertySheetPixmapValue(m_path))).pixmap(16, 16));
+ m_copyAction->setEnabled(true);
+ }
}
}
void PixmapEditor::setDefaultPixmap(const QPixmap &pixmap)
{
m_defaultPixmap = QIcon(pixmap).pixmap(16, 16);
- if (m_path.isEmpty())
+ const bool hasThemeIcon = m_iconThemeModeEnabled && QIcon::hasThemeIcon(m_theme);
+ if (!hasThemeIcon && m_path.isEmpty())
m_pixmapLabel->setPixmap(m_defaultPixmap);
}
@@ -408,6 +521,10 @@ void PixmapEditor::contextMenuEvent(QContextMenuEvent *event)
void PixmapEditor::defaultActionActivated()
{
+ if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(m_theme)) {
+ themeActionActivated();
+ return;
+ }
// Default to resource
const PropertySheetPixmapValue::PixmapSource ps = m_path.isEmpty() ? PropertySheetPixmapValue::ResourcePixmap : PropertySheetPixmapValue::getPixmapSource(m_core, m_path);
switch (ps) {
@@ -426,6 +543,7 @@ void PixmapEditor::resourceActionActivated()
const QString oldPath = m_path;
const QString newPath = IconSelector::choosePixmapResource(m_core, m_core->resourceModel(), oldPath, this);
if (!newPath.isEmpty() && newPath != oldPath) {
+ setTheme(QString());
setPath(newPath);
emit pathChanged(newPath);
}
@@ -435,15 +553,30 @@ void PixmapEditor::fileActionActivated()
{
const QString newPath = IconSelector::choosePixmapFile(m_path, m_core->dialogGui(), this);
if (!newPath.isEmpty() && newPath != m_path) {
+ setTheme(QString());
setPath(newPath);
emit pathChanged(newPath);
}
}
+void PixmapEditor::themeActionActivated()
+{
+ bool ok;
+ const QString newTheme = IconThemeDialog::getTheme(this, m_theme, &ok);
+ if (ok && newTheme != m_theme) {
+ setTheme(newTheme);
+ setPath(QString());
+ emit themeChanged(newTheme);
+ }
+}
+
void PixmapEditor::copyActionActivated()
{
QClipboard *clipboard = QApplication::clipboard();
- clipboard->setText(m_path);
+ if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(m_theme))
+ clipboard->setText(m_theme);
+ else
+ clipboard->setText(m_path);
}
void PixmapEditor::pasteActionActivated()
@@ -455,8 +588,15 @@ void PixmapEditor::pasteActionActivated()
QStringList list = text.split(QLatin1Char('\n'));
if (list.size() > 0) {
text = list.at(0);
- setPath(text);
- emit pathChanged(text);
+ if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(text)) {
+ setTheme(text);
+ setPath(QString());
+ emit themeChanged(text);
+ } else {
+ setPath(text);
+ setTheme(QString());
+ emit pathChanged(text);
+ }
}
}
}
@@ -807,8 +947,13 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari
} else if (QtProperty *iProperty = m_iconSubPropertyToProperty.value(property, 0)) {
QtVariantProperty *iconProperty = variantProperty(iProperty);
PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(iconProperty->value());
- QPair<QIcon::Mode, QIcon::State> pair = m_iconSubPropertyToState.value(property);
- icon.setPixmap(pair.first, pair.second, qvariant_cast<PropertySheetPixmapValue>(value));
+ QMap<QtProperty *, QPair<QIcon::Mode, QIcon::State> >::ConstIterator itState = m_iconSubPropertyToState.constFind(property);
+ if (itState != m_iconSubPropertyToState.constEnd()) {
+ QPair<QIcon::Mode, QIcon::State> pair = m_iconSubPropertyToState.value(property);
+ icon.setPixmap(pair.first, pair.second, qvariant_cast<PropertySheetPixmapValue>(value));
+ } else { // must be theme property
+ icon.setTheme(value.toString());
+ }
QtProperty *origSourceOfChange = m_sourceOfChange;
if (!origSourceOfChange)
m_sourceOfChange = property;
@@ -859,12 +1004,16 @@ void DesignerPropertyManager::slotPropertyDestroyed(QtProperty *property)
m_keySequenceToDisambiguation.remove(keySequenceDisambiguationProperty);
m_disambiguationToKeySequence.remove(property);
} else if (QtProperty *iconProperty = m_iconSubPropertyToProperty.value(property, 0)) {
- QMap<QtProperty *, QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> >::iterator it =
- m_propertyToIconSubProperties.find(iconProperty);
- QPair<QIcon::Mode, QIcon::State> state = m_iconSubPropertyToState.value(property);
- QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> &propertyList = it.value();
- propertyList.remove(state);
- m_iconSubPropertyToState.remove(property);
+ if (m_propertyToTheme.value(iconProperty) == property) {
+ m_propertyToTheme.remove(iconProperty);
+ } else {
+ QMap<QtProperty *, QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> >::iterator it =
+ m_propertyToIconSubProperties.find(iconProperty);
+ QPair<QIcon::Mode, QIcon::State> state = m_iconSubPropertyToState.value(property);
+ QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> &propertyList = it.value();
+ propertyList.remove(state);
+ m_iconSubPropertyToState.remove(property);
+ }
m_iconSubPropertyToProperty.remove(property);
} else {
m_fontManager.slotPropertyDestroyed(property);
@@ -887,6 +1036,7 @@ QStringList DesignerPropertyManager::attributes(int propertyType) const
} else if (propertyType == designerStringTypeId() || propertyType == QVariant::String) {
list.append(QLatin1String(validationModesAttributeC));
list.append(QLatin1String(fontAttributeC));
+ list.append(QLatin1String(themeAttributeC));
} else if (propertyType == QVariant::Palette) {
list.append(QLatin1String(superPaletteAttributeC));
}
@@ -912,6 +1062,8 @@ int DesignerPropertyManager::attributeType(int propertyType, const QString &attr
return QVariant::Int;
if (attribute == QLatin1String(fontAttributeC))
return QVariant::Font;
+ if (attribute == QLatin1String(themeAttributeC))
+ return QVariant::Bool;
}
if (propertyType == QVariant::Palette && attribute == QLatin1String(superPaletteAttributeC))
return QVariant::Palette;
@@ -949,6 +1101,12 @@ QVariant DesignerPropertyManager::attributeValue(const QtProperty *property, con
return it.value();
}
+ if (attribute == QLatin1String(themeAttributeC)) {
+ const PropertyBoolMap::const_iterator it = m_stringThemeAttributes.constFind(prop);
+ if (it != m_stringThemeAttributes.constEnd())
+ return it.value();
+ }
+
if (attribute == QLatin1String(superPaletteAttributeC)) {
PropertyPaletteDataMap::const_iterator it = m_paletteValues.constFind(prop);
if (it != m_paletteValues.constEnd())
@@ -1057,6 +1215,21 @@ void DesignerPropertyManager::setAttribute(QtProperty *property,
it.value() = newValue;
emit attributeChanged(property, attribute, newValue);
+ } else if (attribute == QLatin1String(themeAttributeC) && m_stringThemeAttributes.contains(property)) {
+ if (value.userType() != QVariant::Bool)
+ return;
+
+ const PropertyBoolMap::iterator it = m_stringThemeAttributes.find(property);
+ const bool oldValue = it.value();
+
+ const bool newValue = value.toBool();
+
+ if (oldValue == newValue)
+ return;
+
+ it.value() = newValue;
+
+ emit attributeChanged(property, attribute, newValue);
} else if (attribute == QLatin1String(superPaletteAttributeC) && m_paletteValues.contains(property)) {
if (value.userType() != QVariant::Palette)
return;
@@ -1234,7 +1407,11 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const
return inherited;
}
if (m_iconValues.contains(const_cast<QtProperty *>(property))) {
- const PropertySheetIconValue::ModeStateToPixmapMap paths = m_iconValues.value(const_cast<QtProperty *>(property)).paths();
+ const PropertySheetIconValue icon = m_iconValues.value(const_cast<QtProperty *>(property));
+ const QString theme = icon.theme();
+ if (!theme.isEmpty() && QIcon::hasThemeIcon(theme))
+ return tr("[Theme] %1").arg(theme);
+ const PropertySheetIconValue::ModeStateToPixmapMap paths = icon.paths();
const PropertySheetIconValue::ModeStateToPixmapMap::const_iterator it = paths.constFind(qMakePair(QIcon::Normal, QIcon::Off));
if (it == paths.constEnd())
return QString();
@@ -1339,6 +1516,8 @@ QIcon DesignerPropertyManager::valueIcon(const QtProperty *property) const
qdesigner_internal::FormWindowBase *fwb = qobject_cast<qdesigner_internal::FormWindowBase *>(formWindow);
if (fwb)
return fwb->pixmapCache()->pixmap(m_pixmapValues.value(const_cast<QtProperty *>(property)));
+ } else if (m_stringThemeAttributes.value(const_cast<QtProperty *>(property), false)) {
+ return QIcon::fromTheme(value(property).toString());
} else {
QIcon rc;
if (m_brushManager.valueIcon(property, &rc))
@@ -1604,6 +1783,12 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val
subProperty->setAttribute(QLatin1String(defaultResourceAttributeC),
defaultIcon.pixmap(16, 16, pair.first, pair.second));
}
+ QtVariantProperty *themeSubProperty = variantProperty(m_propertyToTheme.value(property));
+ if (themeSubProperty) {
+ const QString theme = icon.theme();
+ themeSubProperty->setModified(!theme.isEmpty());
+ themeSubProperty->setValue(theme);
+ }
emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(icon));
emit propertyChanged(property);
@@ -1766,6 +1951,7 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property)
case QVariant::String:
m_stringAttributes[property] = ValidationSingleLine;
m_stringFontAttributes[property] = QApplication::font();
+ m_stringThemeAttributes[property] = false;
break;
case QVariant::UInt:
m_uintValues[property] = 0;
@@ -1820,6 +2006,13 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property)
m_iconValues[property] = PropertySheetIconValue();
m_defaultIcons[property] = QIcon();
+ QtVariantProperty *themeProp = addProperty(QVariant::String, tr("Theme"));
+ themeProp->setAttribute(QLatin1String(themeAttributeC), true);
+ m_iconSubPropertyToProperty[themeProp] = property;
+ m_propertyToTheme[property] = themeProp;
+ m_resetMap[themeProp] = true;
+ property->addSubProperty(themeProp);
+
createIconSubProperty(property, QIcon::Normal, QIcon::Off, tr("Normal Off"));
createIconSubProperty(property, QIcon::Normal, QIcon::On, tr("Normal On"));
createIconSubProperty(property, QIcon::Disabled, QIcon::Off, tr("Disabled Off"));
@@ -1833,6 +2026,7 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property)
m_stringValues[property] = val;
m_stringAttributes[property] = ValidationMultiLine;
m_stringFontAttributes[property] = QApplication::font();
+ m_stringThemeAttributes[property] = false;
QtVariantProperty *translatable = addProperty(QVariant::Bool, tr("translatable"));
translatable->setValue(val.translatable());
@@ -1921,37 +2115,43 @@ void DesignerPropertyManager::uninitializeProperty(QtProperty *property)
QtProperty *stringComment = m_stringToComment.value(property);
if (stringComment) {
delete stringComment;
- m_stringToComment.remove(stringComment);
+ m_commentToString.remove(stringComment);
}
QtProperty *stringTranslatable = m_stringToTranslatable.value(property);
if (stringTranslatable) {
delete stringTranslatable;
- m_stringToTranslatable.remove(stringTranslatable);
+ m_translatableToString.remove(stringTranslatable);
}
QtProperty *stringDisambiguation = m_stringToDisambiguation.value(property);
if (stringDisambiguation) {
delete stringDisambiguation;
- m_stringToDisambiguation.remove(stringDisambiguation);
+ m_disambiguationToString.remove(stringDisambiguation);
}
QtProperty *keySequenceComment = m_keySequenceToComment.value(property);
if (keySequenceComment) {
delete keySequenceComment;
- m_keySequenceToComment.remove(keySequenceComment);
+ m_commentToKeySequence.remove(keySequenceComment);
}
QtProperty *keySequenceTranslatable = m_keySequenceToTranslatable.value(property);
if (keySequenceTranslatable) {
delete keySequenceTranslatable;
- m_keySequenceToTranslatable.remove(keySequenceTranslatable);
+ m_translatableToKeySequence.remove(keySequenceTranslatable);
}
QtProperty *keySequenceDisambiguation = m_keySequenceToDisambiguation.value(property);
if (keySequenceDisambiguation) {
delete keySequenceDisambiguation;
- m_keySequenceToDisambiguation.remove(keySequenceDisambiguation);
+ m_disambiguationToKeySequence.remove(keySequenceDisambiguation);
+ }
+
+ QtProperty *iconTheme = m_propertyToTheme.value(property);
+ if (iconTheme) {
+ delete iconTheme;
+ m_iconSubPropertyToProperty.remove(iconTheme);
}
m_propertyToAlignH.remove(property);
@@ -2010,15 +2210,20 @@ bool DesignerPropertyManager::resetFontSubProperty(QtProperty *property)
bool DesignerPropertyManager::resetIconSubProperty(QtProperty *property)
{
- if (!m_iconSubPropertyToProperty.contains(property))
- return false;
-
- if (!m_pixmapValues.contains(property))
+ QtProperty *iconProperty = m_iconSubPropertyToProperty.value(property);
+ if (!iconProperty)
return false;
- QtVariantProperty *pixmapProperty = variantProperty(property);
- pixmapProperty->setValue(QVariant::fromValue(PropertySheetPixmapValue()));
- return true;
+ if (m_pixmapValues.contains(property)) {
+ QtVariantProperty *pixmapProperty = variantProperty(property);
+ pixmapProperty->setValue(QVariant::fromValue(PropertySheetPixmapValue()));
+ return true;
+ } else if (m_propertyToTheme.contains(iconProperty)) {
+ QtVariantProperty *themeProperty = variantProperty(property);
+ themeProperty->setValue(QString());
+ return true;
+ }
+ return false;
}
// -------- DesignerEditorFactory
@@ -2116,6 +2321,10 @@ void DesignerEditorFactory::slotAttributeChanged(QtProperty *property, const QSt
const QFont font = qvariant_cast<QFont>(value);
applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setRichTextDefaultFont, font);
}
+ if (attribute == QLatin1String(themeAttributeC)) {
+ const bool themeEnabled = value.toBool();
+ applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setIconThemeModeEnabled, themeEnabled);
+ }
} else if (type == QVariant::Palette && attribute == QLatin1String(superPaletteAttributeC)) {
const QPalette palette = qvariant_cast<QPalette>(value);
applyToEditors(m_palettePropertyToEditors.value(property), &PaletteEditorButton::setSuperPalette, palette);
@@ -2174,14 +2383,18 @@ void DesignerEditorFactory::slotValueChanged(QtProperty *property, const QVarian
applyToEditors(m_stringListPropertyToEditors.value(property), &StringListEditorButton::setStringList, value.toStringList());
break;
default:
- if (type == DesignerPropertyManager::designerIconTypeId())
- applyToEditors(m_iconPropertyToEditors.value(property), &PixmapEditor::setPath, qvariant_cast<PropertySheetIconValue>(value).pixmap(QIcon::Normal, QIcon::Off).path());
- else if (type == DesignerPropertyManager::designerPixmapTypeId())
+ if (type == DesignerPropertyManager::designerIconTypeId()) {
+ PropertySheetIconValue iconValue = qvariant_cast<PropertySheetIconValue>(value);
+ const QString theme = iconValue.theme();
+ applyToEditors(m_iconPropertyToEditors.value(property), &PixmapEditor::setTheme, iconValue.theme());
+ applyToEditors(m_iconPropertyToEditors.value(property), &PixmapEditor::setPath, iconValue.pixmap(QIcon::Normal, QIcon::Off).path());
+ } else if (type == DesignerPropertyManager::designerPixmapTypeId()) {
applyToEditors(m_pixmapPropertyToEditors.value(property), &PixmapEditor::setPath, qvariant_cast<PropertySheetPixmapValue>(value).path());
- else if (type == DesignerPropertyManager::designerStringTypeId())
+ } else if (type == DesignerPropertyManager::designerStringTypeId()) {
applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setText, qvariant_cast<PropertySheetStringValue>(value).value());
- else if (type == DesignerPropertyManager::designerKeySequenceTypeId())
+ } else if (type == DesignerPropertyManager::designerKeySequenceTypeId()) {
applyToEditors(m_keySequencePropertyToEditors.value(property), &QtKeySequenceEdit::setKeySequence, qvariant_cast<PropertySheetKeySequenceValue>(value).value());
+ }
break;
}
}
@@ -2215,6 +2428,8 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager,
const QVariant richTextDefaultFont = manager->attributeValue(property, QLatin1String(fontAttributeC));
if (richTextDefaultFont.type() == QVariant::Font)
ed->setRichTextDefaultFont(qvariant_cast<QFont>(richTextDefaultFont));
+ const bool themeEnabled = manager->attributeValue(property, QLatin1String(themeAttributeC)).toBool();
+ ed->setIconThemeModeEnabled(themeEnabled);
m_stringPropertyToEditors[property].append(ed);
m_editorToStringProperty[ed] = property;
connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
@@ -2308,7 +2523,9 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager,
} else if (type == DesignerPropertyManager::designerIconTypeId()) {
PixmapEditor *ed = new PixmapEditor(m_core, parent);
ed->setPixmapCache(m_fwb->pixmapCache());
+ ed->setIconThemeModeEnabled(true);
PropertySheetIconValue value = qvariant_cast<PropertySheetIconValue>(manager->value(property));
+ ed->setTheme(value.theme());
ed->setPath(value.pixmap(QIcon::Normal, QIcon::Off).path());
QPixmap defaultPixmap;
if (!property->isModified())
@@ -2321,6 +2538,7 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager,
m_editorToIconProperty[ed] = property;
connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
connect(ed, SIGNAL(pathChanged(QString)), this, SLOT(slotIconChanged(QString)));
+ connect(ed, SIGNAL(themeChanged(QString)), this, SLOT(slotIconThemeChanged(QString)));
editor = ed;
} else if (type == DesignerPropertyManager::designerStringTypeId()) {
const TextPropertyValidationMode tvm = static_cast<TextPropertyValidationMode>(manager->attributeValue(property, QLatin1String(validationModesAttributeC)).toInt());
@@ -2512,6 +2730,14 @@ void DesignerEditorFactory::slotIconChanged(const QString &value)
QVariant::fromValue(PropertySheetIconValue(PropertySheetPixmapValue(value))));
}
+void DesignerEditorFactory::slotIconThemeChanged(const QString &value)
+{
+ PropertySheetIconValue icon;
+ icon.setTheme(value);
+ updateManager(this, &m_changingPropertyValue, m_editorToIconProperty, qobject_cast<QWidget *>(sender()),
+ QVariant::fromValue(icon));
+}
+
void DesignerEditorFactory::slotStringListChanged(const QStringList &value)
{
updateManager(this, &m_changingPropertyValue, m_editorToStringListProperty, qobject_cast<QWidget *>(sender()), QVariant::fromValue(value));
diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.h b/tools/designer/src/components/propertyeditor/designerpropertymanager.h
index 11f900b..03e3dca 100644
--- a/tools/designer/src/components/propertyeditor/designerpropertymanager.h
+++ b/tools/designer/src/components/propertyeditor/designerpropertymanager.h
@@ -180,6 +180,7 @@ private:
QMap<QtProperty *, QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> > m_propertyToIconSubProperties;
QMap<QtProperty *, QPair<QIcon::Mode, QIcon::State> > m_iconSubPropertyToState;
PropertyToPropertyMap m_iconSubPropertyToProperty;
+ PropertyToPropertyMap m_propertyToTheme;
QMap<QtProperty *, qdesigner_internal::PropertySheetStringValue> m_stringValues;
QMap<QtProperty *, QtProperty *> m_stringToComment;
@@ -221,6 +222,7 @@ private:
PropertyIntMap m_stringAttributes;
typedef QMap<QtProperty *, QFont> PropertyFontMap;
PropertyFontMap m_stringFontAttributes;
+ PropertyBoolMap m_stringThemeAttributes;
BrushPropertyManager m_brushManager;
FontPropertyManager m_fontManager;
@@ -261,6 +263,7 @@ private slots:
void slotPaletteChanged(const QPalette &value);
void slotPixmapChanged(const QString &value);
void slotIconChanged(const QString &value);
+ void slotIconThemeChanged(const QString &value);
void slotUintChanged(const QString &value);
void slotLongLongChanged(const QString &value);
void slotULongLongChanged(const QString &value);
diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.pri b/tools/designer/src/components/propertyeditor/propertyeditor.pri
index 7d2e7cb..bb1afdb 100644
--- a/tools/designer/src/components/propertyeditor/propertyeditor.pri
+++ b/tools/designer/src/components/propertyeditor/propertyeditor.pri
@@ -45,10 +45,8 @@ SOURCES += $$PWD/propertyeditor.cpp \
HEADERS += \
$$PWD/propertyeditor_global.h \
- $$PWD/defs.h \
$$PWD/qlonglongvalidator.h
-SOURCES += $$PWD/defs.cpp \
- $$PWD/qlonglongvalidator.cpp
+SOURCES += $$PWD/qlonglongvalidator.cpp
RESOURCES += $$PWD/propertyeditor.qrc
diff --git a/tools/designer/src/components/taskmenu/itemlisteditor.cpp b/tools/designer/src/components/taskmenu/itemlisteditor.cpp
index 29fe0c9..b2ca134 100644
--- a/tools/designer/src/components/taskmenu/itemlisteditor.cpp
+++ b/tools/designer/src/components/taskmenu/itemlisteditor.cpp
@@ -114,20 +114,20 @@ void AbstractItemEditor::keyPressEvent(QKeyEvent *e)
}
static const char * const itemFlagNames[] = {
- "Selectable",
- "Editable",
- "DragEnabled",
- "DropEnabled",
- "UserCheckable",
- "Enabled",
- "Tristate",
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Selectable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Editable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "DragEnabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "DropEnabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "UserCheckable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Enabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Tristate"),
0
};
static const char * const checkStateNames[] = {
- "Unchecked",
- "PartiallyChecked",
- "Checked",
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Unchecked"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "PartiallyChecked"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Checked"),
0
};
@@ -135,7 +135,7 @@ static QStringList c2qStringList(const char * const in[])
{
QStringList out;
for (int i = 0; in[i]; i++)
- out << QLatin1String(in[i]);
+ out << AbstractItemEditor::tr(in[i]);
return out;
}
diff --git a/tools/designer/src/lib/sdk/abstractintegration.cpp b/tools/designer/src/lib/sdk/abstractintegration.cpp
index c5a60db..3924db6 100644
--- a/tools/designer/src/lib/sdk/abstractintegration.cpp
+++ b/tools/designer/src/lib/sdk/abstractintegration.cpp
@@ -42,13 +42,64 @@
#include "abstractintegration.h"
#include "abstractformeditor.h"
+#include <QtCore/QVariant>
+#include <QtCore/QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+// Add 'private' struct as a dynamic property.
+
+static const char privatePropertyC[] = "_q_integrationprivate";
+
+struct QDesignerIntegrationInterfacePrivate {
+ QDesignerIntegrationInterfacePrivate() :
+ headerSuffix(QLatin1String(".h")),
+ headerLowercase(true) {}
+
+ QString headerSuffix;
+ bool headerLowercase;
+};
+
+typedef QSharedPointer<QDesignerIntegrationInterfacePrivate> QDesignerIntegrationInterfacePrivatePtr;
+
+QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QDesignerIntegrationInterfacePrivatePtr))
QT_BEGIN_NAMESPACE
+static QDesignerIntegrationInterfacePrivatePtr integrationD(const QObject *o)
+{
+ const QVariant property = o->property(privatePropertyC);
+ Q_ASSERT(qVariantCanConvert<QDesignerIntegrationInterfacePrivatePtr>(property));
+ return qvariant_cast<QDesignerIntegrationInterfacePrivatePtr>(property);
+}
+
QDesignerIntegrationInterface::QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent)
: QObject(parent),
m_core(core)
{
core->setIntegration(this);
+ const QDesignerIntegrationInterfacePrivatePtr d(new QDesignerIntegrationInterfacePrivate);
+ setProperty(privatePropertyC, qVariantFromValue<QDesignerIntegrationInterfacePrivatePtr>(d));
+}
+
+QString QDesignerIntegrationInterface::headerSuffix() const
+{
+ return integrationD(this)->headerSuffix;
+}
+
+void QDesignerIntegrationInterface::setHeaderSuffix(const QString &headerSuffix)
+{
+ integrationD(this)->headerSuffix = headerSuffix;
+}
+
+bool QDesignerIntegrationInterface::isHeaderLowercase() const
+{
+ return integrationD(this)->headerLowercase;
+}
+
+void QDesignerIntegrationInterface::setHeaderLowercase(bool headerLowercase)
+{
+ integrationD(this)->headerLowercase = headerLowercase;
}
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/sdk/abstractintegration.h b/tools/designer/src/lib/sdk/abstractintegration.h
index 9b2b856..acac711 100644
--- a/tools/designer/src/lib/sdk/abstractintegration.h
+++ b/tools/designer/src/lib/sdk/abstractintegration.h
@@ -45,6 +45,7 @@
#include <QtDesigner/sdk_global.h>
#include <QtCore/QObject>
+#include <QtCore/QString>
QT_BEGIN_HEADER
@@ -55,6 +56,9 @@ class QDesignerFormEditorInterface;
class QDESIGNER_SDK_EXPORT QDesignerIntegrationInterface: public QObject
{
Q_OBJECT
+ Q_PROPERTY(QString headerSuffix READ headerSuffix WRITE setHeaderSuffix)
+ Q_PROPERTY(bool headerLowercase READ isHeaderLowercase WRITE setHeaderLowercase)
+
public:
QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent = 0);
@@ -62,6 +66,12 @@ public:
virtual QWidget *containerWindow(QWidget *widget) const = 0;
+ QString headerSuffix() const;
+ void setHeaderSuffix(const QString &headerSuffix);
+
+ bool isHeaderLowercase() const;
+ void setHeaderLowercase(bool headerLowerCase);
+
private:
QDesignerFormEditorInterface *m_core;
};
diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp
index d3716ca..9664a22 100644
--- a/tools/designer/src/lib/shared/actioneditor.cpp
+++ b/tools/designer/src/lib/shared/actioneditor.cpp
@@ -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);
@@ -480,7 +479,7 @@ 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;
diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp
index 8df6f83..40801f2 100644
--- a/tools/designer/src/lib/shared/actionrepository.cpp
+++ b/tools/designer/src/lib/shared/actionrepository.cpp
@@ -397,9 +397,10 @@ void ActionTreeView::contextMenuEvent(QContextMenuEvent *event)
emit contextMenuRequested(event, m_model->actionAt(indexAt(event->pos())));
}
-void ActionTreeView::currentChanged(const QModelIndex &current, const QModelIndex &/*previous*/)
+void ActionTreeView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
emit currentChanged(m_model->actionAt(current));
+ QTreeView::currentChanged(current, previous);
}
void ActionTreeView::slotActivated(const QModelIndex &index)
@@ -478,9 +479,10 @@ void ActionListView::contextMenuEvent(QContextMenuEvent *event)
emit contextMenuRequested(event, m_model->actionAt(indexAt(event->pos())));
}
-void ActionListView::currentChanged(const QModelIndex &current, const QModelIndex & /*previous*/)
+void ActionListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
emit currentChanged(m_model->actionAt(current));
+ QListView::currentChanged(current, previous);
}
void ActionListView::slotActivated(const QModelIndex &index)
diff --git a/tools/designer/src/lib/shared/iconselector.cpp b/tools/designer/src/lib/shared/iconselector.cpp
index 4bb7430..ef20cd2 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 3373f80..5fa8f80 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/newactiondialog.cpp b/tools/designer/src/lib/shared/newactiondialog.cpp
index b411464..e6c95f6 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 f9cafd1..ca5406f 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/plugindialog.cpp b/tools/designer/src/lib/shared/plugindialog.cpp
index 3e88043..63ba81c 100644
--- a/tools/designer/src/lib/shared/plugindialog.cpp
+++ b/tools/designer/src/lib/shared/plugindialog.cpp
@@ -102,7 +102,7 @@ void PluginDialog::populateTreeWidget()
const QStringList fileNames = pluginManager->registeredPlugins();
if (!fileNames.isEmpty()) {
- QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Loaded Plugins"));
+ QTreeWidgetItem *topLevelItem = setTopLevelItem(tr("Loaded Plugins"));
QFont boldFont = topLevelItem->font(0);
foreach (const QString &fileName, fileNames) {
@@ -125,7 +125,7 @@ void PluginDialog::populateTreeWidget()
const QStringList notLoadedPlugins = pluginManager->failedPlugins();
if (!notLoadedPlugins.isEmpty()) {
- QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Failed Plugins"));
+ QTreeWidgetItem *topLevelItem = setTopLevelItem(tr("Failed Plugins"));
const QFont boldFont = topLevelItem->font(0);
foreach (const QString &plugin, notLoadedPlugins) {
const QString failureReason = pluginManager->failureReason(plugin);
diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
index eca6615..1fbfccb 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 1e63d81..f2a2b2a 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_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
index 72ecb8f..ee05adf 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
@@ -1065,8 +1065,8 @@ QVariant QDesignerPropertySheet::resolvePropertyValue(int index, const QVariant
}
if (value.canConvert<qdesigner_internal::PropertySheetIconValue>()) {
- const int pathCount = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value).paths().count();
- if (pathCount == 0)
+ 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));
diff --git a/tools/designer/src/lib/shared/qdesigner_utils.cpp b/tools/designer/src/lib/shared/qdesigner_utils.cpp
index de3e387..bd89c53 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>
@@ -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 bed1d05..b310208 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
diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp
index ad2aa05..3f40d81 100644
--- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp
+++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp
@@ -1381,9 +1381,83 @@ DomActionRef *QAbstractFormBuilder::createActionRefDom(QAction *action)
return ui_action_ref;
}
+// Struct to store layout item parameters for saving layout items
+struct FormBuilderSaveLayoutEntry {
+ explicit FormBuilderSaveLayoutEntry(QLayoutItem *li = 0) :
+ item(li), row(-1), column(-1), rowSpan(0), columnSpan(0) {}
+
+ QLayoutItem *item;
+ int row;
+ int column;
+ int rowSpan;
+ int columnSpan;
+};
+
+// Create list from standard box layout
+static QList<FormBuilderSaveLayoutEntry> saveLayoutEntries(const QLayout *layout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = layout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = layout->itemAt(idx);
+ rc.append(FormBuilderSaveLayoutEntry(item));
+ }
+ }
+ return rc;
+}
+
+// Create list from grid layout
+static QList<FormBuilderSaveLayoutEntry> saveGridLayoutEntries(QGridLayout *gridLayout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = gridLayout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = gridLayout->itemAt(idx);
+ FormBuilderSaveLayoutEntry entry(item);
+ gridLayout->getItemPosition(idx, &entry.row, &entry.column, &entry.rowSpan,&entry.columnSpan);
+ rc.append(entry);
+ }
+ }
+ return rc;
+}
+
+#ifndef QT_NO_FORMLAYOUT
+// Create list from form layout
+static QList<FormBuilderSaveLayoutEntry> saveFormLayoutEntries(const QFormLayout *formLayout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = formLayout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = formLayout->itemAt(idx);
+ QFormLayout::ItemRole role = QFormLayout::LabelRole;
+ FormBuilderSaveLayoutEntry entry(item);
+ formLayout->getItemPosition(idx, &entry.row, &role);
+ switch (role ) {
+ case QFormLayout::LabelRole:
+ entry.column = 0;
+ break;
+ case QFormLayout::FieldRole:
+ entry.column = 1;
+ break;
+ case QFormLayout::SpanningRole:
+ entry.column = 0;
+ entry.columnSpan = 2;
+ break;
+ }
+ rc.push_back(entry);
+ }
+ }
+ return rc;
+}
+#endif
+
/*!
\internal
*/
+
DomLayout *QAbstractFormBuilder::createDom(QLayout *layout, DomLayout *ui_layout, DomWidget *ui_parentWidget)
{
Q_UNUSED(ui_layout)
@@ -1394,37 +1468,30 @@ DomLayout *QAbstractFormBuilder::createDom(QLayout *layout, DomLayout *ui_layout
lay->setAttributeName(objectName);
lay->setElementProperty(computeProperties(layout));
- QList<DomLayoutItem*> ui_items;
-
- QMap<QObject *, QLayoutItem *> objectToItem;
- QList<QLayoutItem *> spacerItems;
- QList<QLayoutItem *> newList;
-
- for (int idx=0; layout->itemAt(idx); ++idx) {
- QLayoutItem *item = layout->itemAt(idx);
- if (item->widget())
- objectToItem[item->widget()] = item;
- else if (item->layout())
- objectToItem[item->layout()] = item;
- else if (item->spacerItem())
- spacerItems.append(item);
- newList.append(item);
- }
-
- if (qobject_cast<QGridLayout *>(layout)) {
- newList.clear();
- QList<QObject *> childrenList = layout->parentWidget()->children();
- foreach (QObject *o, childrenList) {
- if (objectToItem.contains(o))
- newList.append(objectToItem[o]);
- }
- newList += spacerItems;
+ QList<FormBuilderSaveLayoutEntry> newList;
+ if (QGridLayout *gridLayout = qobject_cast<QGridLayout *>(layout)) {
+ newList = saveGridLayoutEntries(gridLayout);
+#ifndef QT_NO_FORMLAYOUT
+ } else if (const QFormLayout *formLayout = qobject_cast<const QFormLayout *>(layout)) {
+ newList = saveFormLayoutEntries(formLayout);
+#endif
+ } else {
+ newList = saveLayoutEntries(layout);
}
- foreach (QLayoutItem *item, newList) {
- DomLayoutItem *ui_item = createDom(item, lay, ui_parentWidget);
- if (ui_item)
+ QList<DomLayoutItem*> ui_items;
+ foreach (const FormBuilderSaveLayoutEntry &item, newList) {
+ if (DomLayoutItem *ui_item = createDom(item.item, lay, ui_parentWidget)) {
+ if (item.row >= 0)
+ ui_item->setAttributeRow(item.row);
+ if (item.column >= 0)
+ ui_item->setAttributeColumn(item.column);
+ if (item.rowSpan > 1)
+ ui_item->setAttributeRowSpan(item.rowSpan);
+ if (item.columnSpan > 1)
+ ui_item->setAttributeColSpan(item.columnSpan);
ui_items.append(ui_item);
+ }
}
lay->setElementItem(ui_items);
diff --git a/tools/designer/src/lib/uilib/resourcebuilder.cpp b/tools/designer/src/lib/uilib/resourcebuilder.cpp
index d19a09a..03e2a66 100644
--- a/tools/designer/src/lib/uilib/resourcebuilder.cpp
+++ b/tools/designer/src/lib/uilib/resourcebuilder.cpp
@@ -44,6 +44,7 @@
#include <QtCore/QVariant>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
+#include <QtCore/QDebug>
#include <QtGui/QPixmap>
#include <QtGui/QIcon>
@@ -53,6 +54,8 @@ QT_BEGIN_NAMESPACE
namespace QFormInternal {
#endif
+enum { themeDebug = 0 };
+
QResourceBuilder::QResourceBuilder()
{
@@ -95,6 +98,14 @@ QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomP
}
case DomProperty::IconSet: {
const DomResourceIcon *dpi = property->elementIconSet();
+ if (!dpi->attributeTheme().isEmpty()) {
+ const QString theme = dpi->attributeTheme();
+ const bool known = QIcon::hasThemeIcon(theme);
+ if (themeDebug)
+ qDebug("Theme %s known %d", qPrintable(theme), known);
+ if (known)
+ return qVariantFromValue(QIcon::fromTheme(dpi->attributeTheme()));
+ } // non-empty theme
if (const int flags = iconStateFlags(dpi)) { // new, post 4.4 format
QIcon icon;
if (flags & NormalOff)
diff --git a/tools/designer/src/lib/uilib/ui4.cpp b/tools/designer/src/lib/uilib/ui4.cpp
index c13bd59..98974e6 100644
--- a/tools/designer/src/lib/uilib/ui4.cpp
+++ b/tools/designer/src/lib/uilib/ui4.cpp
@@ -7745,6 +7745,7 @@ void DomResourceIcon::clear(bool clear_all)
if (clear_all) {
m_text = QLatin1String("");
+ m_has_attr_theme = false;
m_has_attr_resource = false;
}
@@ -7762,6 +7763,7 @@ void DomResourceIcon::clear(bool clear_all)
DomResourceIcon::DomResourceIcon()
{
m_children = 0;
+ m_has_attr_theme = false;
m_has_attr_resource = false;
m_text = QLatin1String("");
m_normalOff = 0;
@@ -7791,6 +7793,10 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
QStringRef name = attribute.name();
+ if (name == QLatin1String("theme")) {
+ setAttributeTheme(attribute.value().toString());
+ continue;
+ }
if (name == QLatin1String("resource")) {
setAttributeResource(attribute.value().toString());
continue;
@@ -7869,6 +7875,8 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
#ifdef QUILOADER_QDOM_READ
void DomResourceIcon::read(const QDomElement &node)
{
+ if (node.hasAttribute(QLatin1String("theme")))
+ setAttributeTheme(node.attribute(QLatin1String("theme")));
if (node.hasAttribute(QLatin1String("resource")))
setAttributeResource(node.attribute(QLatin1String("resource")));
@@ -7938,6 +7946,9 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co
{
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourceicon") : tagName.toLower());
+ if (hasAttributeTheme())
+ writer.writeAttribute(QLatin1String("theme"), attributeTheme());
+
if (hasAttributeResource())
writer.writeAttribute(QLatin1String("resource"), attributeResource());
diff --git a/tools/designer/src/lib/uilib/ui4_p.h b/tools/designer/src/lib/uilib/ui4_p.h
index 1f38f88..a464a89 100644
--- a/tools/designer/src/lib/uilib/ui4_p.h
+++ b/tools/designer/src/lib/uilib/ui4_p.h
@@ -2809,6 +2809,11 @@ public:
inline void setText(const QString &s) { m_text = s; }
// attribute accessors
+ inline bool hasAttributeTheme() const { return m_has_attr_theme; }
+ inline QString attributeTheme() const { return m_attr_theme; }
+ inline void setAttributeTheme(const QString& a) { m_attr_theme = a; m_has_attr_theme = true; }
+ inline void clearAttributeTheme() { m_has_attr_theme = false; }
+
inline bool hasAttributeResource() const { return m_has_attr_resource; }
inline QString attributeResource() const { return m_attr_resource; }
inline void setAttributeResource(const QString& a) { m_attr_resource = a; m_has_attr_resource = true; }
@@ -2868,6 +2873,9 @@ private:
void clear(bool clear_all = true);
// attribute data
+ QString m_attr_theme;
+ bool m_has_attr_theme;
+
QString m_attr_resource;
bool m_has_attr_resource;
diff --git a/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
index c508fa2..7f597ff 100644
--- a/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
@@ -66,12 +66,12 @@ QString SeekSliderPlugin::group() const
QString SeekSliderPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString SeekSliderPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString SeekSliderPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
index d4af121..489a08c 100644
--- a/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
@@ -72,12 +72,12 @@ QString VideoPlayerPlugin::group() const
QString VideoPlayerPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VideoPlayerPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VideoPlayerPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
index becd5d9..24eb829 100644
--- a/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
@@ -66,12 +66,12 @@ QString VolumeSliderPlugin::group() const
QString VolumeSliderPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VolumeSliderPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VolumeSliderPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
index b352a9b..7148ad0 100644
--- a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
+++ b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
@@ -69,12 +69,12 @@ QString QDeclarativeViewPlugin::group() const
QString QDeclarativeViewPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QDeclarativeViewPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QDeclarativeViewPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp b/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
index 61f7e66..c90e191 100644
--- a/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
+++ b/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
@@ -69,12 +69,12 @@ QString QWebViewPlugin::group() const
QString QWebViewPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QWebViewPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QWebViewPlugin::includeFile() const