summaryrefslogtreecommitdiffstats
path: root/tools/designer
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-02-12 10:49:50 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-02-12 10:49:50 (GMT)
commit8e309899b8287b67905072927df1e00effc2a13e (patch)
tree6c7bff1a77090c5b39b35a13c88ef876c2535e09 /tools/designer
parentf74029e286e97067ac39086955481bf979af69dc (diff)
parent01245bcabf97dfdfdd23a2ec075b8de3e78bdeb2 (diff)
downloadQt-8e309899b8287b67905072927df1e00effc2a13e.zip
Qt-8e309899b8287b67905072927df1e00effc2a13e.tar.gz
Qt-8e309899b8287b67905072927df1e00effc2a13e.tar.bz2
Merge remote branch 'origin/4.6' into qt-master-from-4.6
Diffstat (limited to 'tools/designer')
-rw-r--r--tools/designer/src/lib/shared/actionrepository.cpp21
-rw-r--r--tools/designer/src/lib/shared/actionrepository_p.h9
-rw-r--r--tools/designer/src/lib/shared/iconloader.cpp3
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menu.cpp11
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menu_p.h2
5 files changed, 25 insertions, 21 deletions
diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp
index e3ff2c1..1076ff4 100644
--- a/tools/designer/src/lib/shared/actionrepository.cpp
+++ b/tools/designer/src/lib/shared/actionrepository.cpp
@@ -77,18 +77,12 @@ static inline QAction *actionOfItem(const QStandardItem* item)
return qvariant_cast<QAction*>(item->data(qdesigner_internal::ActionModel::ActionRole));
}
-static QIcon fixActionIcon(const QIcon &icon)
-{
- if (icon.isNull())
- return qdesigner_internal::emptyIcon();
- return icon;
-}
-
namespace qdesigner_internal {
// ----------- ActionModel
ActionModel::ActionModel(QWidget *parent ) :
QStandardItemModel(parent),
+ m_emptyIcon(emptyIcon()),
m_core(0)
{
QStringList headers;
@@ -127,7 +121,7 @@ void ActionModel::update(int row)
for (int i = 0; i < NumColumns; i++)
list += item(row, i);
- setItems(m_core, actionOfItem(list.front()), list);
+ setItems(m_core, actionOfItem(list.front()), m_emptyIcon, list);
}
void ActionModel::remove(int row)
@@ -150,7 +144,7 @@ QModelIndex ActionModel::addAction(QAction *action)
item->setFlags(flags);
items.push_back(item);
}
- setItems(m_core, action, items);
+ setItems(m_core, action, m_emptyIcon, items);
appendRow(items);
return indexFromItem(items.front());
}
@@ -185,7 +179,9 @@ PropertySheetKeySequenceValue ActionModel::actionShortCut(const QDesignerPropert
return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index));
}
-void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, QStandardItemList &sl)
+void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
+ const QIcon &defaultIcon,
+ QStandardItemList &sl)
{
// Tooltip, mostly for icon view mode
@@ -200,7 +196,10 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
QStandardItem *item = sl[NameColumn];
item->setText(action->objectName());
- item->setIcon(fixActionIcon(action->icon()));
+ QIcon icon = action->icon();
+ if (icon.isNull())
+ icon = defaultIcon;
+ item->setIcon(icon);
item->setToolTip(firstTooltip);
item->setWhatsThis(firstTooltip);
// Used
diff --git a/tools/designer/src/lib/shared/actionrepository_p.h b/tools/designer/src/lib/shared/actionrepository_p.h
index 65adc5d..6e17e7b 100644
--- a/tools/designer/src/lib/shared/actionrepository_p.h
+++ b/tools/designer/src/lib/shared/actionrepository_p.h
@@ -59,6 +59,7 @@
#include <QtGui/QTreeView>
#include <QtGui/QListView>
#include <QtGui/QStackedWidget>
+#include <QtGui/QIcon>
QT_BEGIN_NAMESPACE
@@ -110,10 +111,14 @@ signals:
void resourceImageDropped(const QString &path, QAction *action);
private:
+ typedef QList<QStandardItem *> QStandardItemList;
+
void initializeHeaders();
+ static void setItems(QDesignerFormEditorInterface *core, QAction *a,
+ const QIcon &defaultIcon,
+ QStandardItemList &sl);
- typedef QList<QStandardItem *> QStandardItemList;
- static void setItems(QDesignerFormEditorInterface *core, QAction *a, QStandardItemList &sl);
+ const QIcon m_emptyIcon;
QDesignerFormEditorInterface *m_core;
};
diff --git a/tools/designer/src/lib/shared/iconloader.cpp b/tools/designer/src/lib/shared/iconloader.cpp
index df0bb7e..ed312b8 100644
--- a/tools/designer/src/lib/shared/iconloader.cpp
+++ b/tools/designer/src/lib/shared/iconloader.cpp
@@ -70,8 +70,7 @@ QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name)
QDESIGNER_SHARED_EXPORT QIcon emptyIcon()
{
- static const QIcon empty_icon(QLatin1String(":/trolltech/formeditor/images/emptyicon.png"));
- return empty_icon;
+ return QIcon(QLatin1String(":/trolltech/formeditor/images/emptyicon.png"));
}
} // namespace qdesigner_internal
diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp
index c83abad..ba512e4 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp
@@ -88,6 +88,7 @@ static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection d
QDesignerMenu::QDesignerMenu(QWidget *parent) :
QMenu(parent),
+ m_subMenuPixmap(QPixmap(QLatin1String(":/trolltech/formeditor/images/submenu.png"))),
m_currentIndex(0),
m_addItem(new SpecialMenuAction(this)),
m_addSeparator(new SpecialMenuAction(this)),
@@ -550,11 +551,10 @@ void QDesignerMenu::deleteAction(QAction *a)
QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const
{
- static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
const QRect g = actionGeometry(action);
- const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - pm.width() - 2) : 2;
- const int y = g.top() + (g.height() - pm.height())/2 + 1;
- return QRect(x, y, pm.width(), pm.height());
+ const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - m_subMenuPixmap.width() - 2) : 2;
+ const int y = g.top() + (g.height() - m_subMenuPixmap.height())/2 + 1;
+ return QRect(x, y, m_subMenuPixmap.width(), m_subMenuPixmap.height());
}
bool QDesignerMenu::hasSubMenuPixmap(QAction *action) const
@@ -591,8 +591,7 @@ void QDesignerMenu::paintEvent(QPaintEvent *event)
p.fillRect(g, lg);
} else if (hasSubMenuPixmap(a)) {
- static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
- p.drawPixmap(subMenuPixmapRect(a).topLeft(), pm);
+ p.drawPixmap(subMenuPixmapRect(a).topLeft(), m_subMenuPixmap);
}
}
diff --git a/tools/designer/src/lib/shared/qdesigner_menu_p.h b/tools/designer/src/lib/shared/qdesigner_menu_p.h
index 9c9a311..ae1e0e7 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_menu_p.h
@@ -57,6 +57,7 @@
#include <QtGui/QAction>
#include <QtGui/QMenu>
+#include <QtGui/QPixmap>
#include <QtCore/QHash>
QT_BEGIN_NAMESPACE
@@ -183,6 +184,7 @@ protected:
private:
bool hideSubMenuOnCursorKey();
bool showSubMenuOnCursorKey();
+ const QPixmap m_subMenuPixmap;
QPoint m_startPosition;
int m_currentIndex;