summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/designer/src/lib')
-rw-r--r--tools/designer/src/lib/lib.pro2
-rw-r--r--tools/designer/src/lib/shared/actioneditor.cpp18
-rw-r--r--tools/designer/src/lib/shared/actionprovider_p.h2
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menu.cpp86
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menu_p.h3
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menubar.cpp58
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menubar_p.h4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_toolbar.cpp2
-rw-r--r--tools/designer/src/lib/shared/qtresourceview.cpp10
9 files changed, 124 insertions, 61 deletions
diff --git a/tools/designer/src/lib/lib.pro b/tools/designer/src/lib/lib.pro
index e0f2f2357..495976d21 100644
--- a/tools/designer/src/lib/lib.pro
+++ b/tools/designer/src/lib/lib.pro
@@ -34,7 +34,7 @@ QMAKE_TARGET_DESCRIPTION = Graphical user interface designer.
#load up the headers info
CONFIG += qt_install_headers
HEADERS_PRI = $$QT_BUILD_TREE/include/QtDesigner/headers.pri
-include($$HEADERS_PRI)|clear(HEADERS_PRI)
+include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI)
#mac frameworks
mac:CONFIG += explicitlib
diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp
index 1a236d6bd..a931b8aaf 100644
--- a/tools/designer/src/lib/shared/actioneditor.cpp
+++ b/tools/designer/src/lib/shared/actioneditor.cpp
@@ -147,7 +147,8 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent,
toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
l->addWidget(toolbar);
// edit actions
- m_actionNew->setIcon(createIconSet(QLatin1String("filenew.png")));
+ QIcon documentNewIcon = QIcon::fromTheme("document-new", createIconSet(QLatin1String("filenew.png")));
+ m_actionNew->setIcon(documentNewIcon);
m_actionNew->setEnabled(false);
connect(m_actionNew, SIGNAL(triggered()), this, SLOT(slotNewAction()));
toolbar->addAction(m_actionNew);
@@ -156,15 +157,18 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent,
m_actionCut->setEnabled(false);
connect(m_actionCut, SIGNAL(triggered()), this, SLOT(slotCut()));
- m_actionCut->setIcon(createIconSet(QLatin1String("editcut.png")));
+ QIcon editCutIcon = QIcon::fromTheme("edit-cut", createIconSet(QLatin1String("editcut.png")));
+ m_actionCut->setIcon(editCutIcon);
m_actionCopy->setEnabled(false);
connect(m_actionCopy, SIGNAL(triggered()), this, SLOT(slotCopy()));
- m_actionCopy->setIcon(createIconSet(QLatin1String("editcopy.png")));
+ QIcon editCopyIcon = QIcon::fromTheme("edit-copy", createIconSet(QLatin1String("editcopy.png")));
+ m_actionCopy->setIcon(editCopyIcon);
toolbar->addAction(m_actionCopy);
connect(m_actionPaste, SIGNAL(triggered()), this, SLOT(slotPaste()));
- m_actionPaste->setIcon(createIconSet(QLatin1String("editpaste.png")));
+ QIcon editPasteIcon = QIcon::fromTheme("edit-paste", createIconSet(QLatin1String("editpaste.png")));
+ m_actionPaste->setIcon(editPasteIcon);
toolbar->addAction(m_actionPaste);
m_actionEdit->setEnabled(false);
@@ -172,7 +176,8 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent,
connect(m_actionNavigateToSlot, SIGNAL(triggered()), this, SLOT(navigateToSlotCurrentAction()));
- m_actionDelete->setIcon(createIconSet(QLatin1String("editdelete.png")));
+ QIcon editDeleteIcon = QIcon::fromTheme("edit-delete", createIconSet(QLatin1String("editdelete.png")));
+ m_actionDelete->setIcon(editDeleteIcon);
m_actionDelete->setEnabled(false);
connect(m_actionDelete, SIGNAL(triggered()), this, SLOT(slotDelete()));
toolbar->addAction(m_actionDelete);
@@ -243,7 +248,8 @@ QToolButton *ActionEditor::createConfigureMenuButton(const QString &t, QMenu **p
{
QToolButton *configureButton = new QToolButton;
QAction *configureAction = new QAction(t, configureButton);
- configureAction->setIcon(createIconSet(QLatin1String("configure.png")));
+ QIcon configureIcon = QIcon::fromTheme("document-properties", createIconSet(QLatin1String("configure.png")));
+ configureAction->setIcon(configureIcon);
QMenu *configureMenu = new QMenu;
configureAction->setMenu(configureMenu);
configureButton->setDefaultAction(configureAction);
diff --git a/tools/designer/src/lib/shared/actionprovider_p.h b/tools/designer/src/lib/shared/actionprovider_p.h
index b43dee993..5f9b7a011 100644
--- a/tools/designer/src/lib/shared/actionprovider_p.h
+++ b/tools/designer/src/lib/shared/actionprovider_p.h
@@ -86,7 +86,7 @@ template <class Widget>
// actionGeometry() can be wrong sometimes; it returns a geometry that
// stretches to the end of the toolbar/menu bar. So, check from the beginning
// in the case of a horizontal right-to-left orientation.
- const bool checkTopRight = orientation == Qt::Horizontal && QApplication::layoutDirection() == Qt::RightToLeft;
+ const bool checkTopRight = orientation == Qt::Horizontal && w->layoutDirection() == Qt::RightToLeft;
const QPoint topRight = QPoint(w->rect().width(), 0);
for (int index = 0; index < actionCount; ++index) {
QRect g = w->actionGeometry(actions.at(index));
diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp
index c727d8e07..6aba65b98 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp
@@ -73,6 +73,19 @@ QT_BEGIN_NAMESPACE
using namespace qdesigner_internal;
+// give the user a little more space to click on the sub menu rectangle
+static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection dir)
+{
+ switch (dir) {
+ case Qt::LeftToRight:
+ subMenuRect->setLeft(subMenuRect->left() - 20);
+ break;
+ case Qt::RightToLeft:
+ subMenuRect->setRight(subMenuRect->right() + 20);
+ break;
+ }
+}
+
QDesignerMenu::QDesignerMenu(QWidget *parent) :
QMenu(parent),
m_currentIndex(0),
@@ -325,8 +338,7 @@ bool QDesignerMenu::handleMouseDoubleClickEvent(QWidget *, QMouseEvent *event)
QRect pm_rect;
if (action->menu() || hasSubMenuPixmap(action)) {
pm_rect = subMenuPixmapRect(action);
- pm_rect.setLeft(pm_rect.left() - 20); // give the user a little more
- // space to click
+ extendClickableArea(&pm_rect, layoutDirection());
}
if (!pm_rect.contains(event->pos()) && m_currentIndex != -1)
@@ -381,7 +393,7 @@ bool QDesignerMenu::handleMousePressEvent(QWidget * /*widget*/, QMouseEvent *eve
QAction *action = safeActionAt(index);
QRect pm_rect = subMenuPixmapRect(action);
- pm_rect.setLeft(pm_rect.left() - 20); // give the user a little more space to click
+ extendClickableArea(&pm_rect, layoutDirection());
const int old_index = m_currentIndex;
m_currentIndex = index;
@@ -540,7 +552,7 @@ QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const
{
static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
const QRect g = actionGeometry(action);
- const int x = g.right() - pm.width() - 2;
+ 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());
}
@@ -863,38 +875,52 @@ void QDesignerMenu::closeMenuChain()
m_lastSubMenuIndex = -1;
}
-void QDesignerMenu::moveLeft()
+// Close submenu using the left/right keys according to layoutDirection().
+// Return false to indicate the event must be propagated to the menu bar.
+bool QDesignerMenu::hideSubMenuOnCursorKey()
{
if (parentMenu()) {
hide();
- } else {
- closeMenuChain();
- if (QDesignerMenuBar *mb = parentMenuBar()) {
- if (QApplication::layoutDirection() == Qt::LeftToRight)
- mb->moveLeft();
- else
- mb->moveRight();
- }
+ return true;
}
+ closeMenuChain();
update();
+ if (parentMenuBar())
+ return false;
+ return true;
}
-void QDesignerMenu::moveRight()
+// Open a submenu using the left/right keys according to layoutDirection().
+// Return false to indicate the event must be propagated to the menu bar.
+bool QDesignerMenu::showSubMenuOnCursorKey()
{
- QAction *action = currentAction();
+ const QAction *action = currentAction();
- if (qobject_cast<SpecialMenuAction*>(action) || action->isSeparator()) {
+ if (qobject_cast<const SpecialMenuAction*>(action) || action->isSeparator()) {
closeMenuChain();
- if (QDesignerMenuBar *mb = parentMenuBar()) {
- if (QApplication::layoutDirection() == Qt::LeftToRight)
- mb->moveRight();
- else
- mb->moveLeft();
- }
- } else {
- m_lastSubMenuIndex = -1; // force a refresh
- slotShowSubMenuNow();
+ if (parentMenuBar())
+ return false;
+ return true;
}
+ m_lastSubMenuIndex = -1; // force a refresh
+ slotShowSubMenuNow();
+ return true;
+}
+
+void QDesignerMenu::moveLeft()
+{
+ const bool handled = layoutDirection() == Qt::LeftToRight ?
+ hideSubMenuOnCursorKey() : showSubMenuOnCursorKey();
+ if (!handled)
+ parentMenuBar()->moveLeft();
+}
+
+void QDesignerMenu::moveRight()
+{
+ const bool handled = layoutDirection() == Qt::LeftToRight ?
+ showSubMenuOnCursorKey() : hideSubMenuOnCursorKey();
+ if (!handled)
+ parentMenuBar()->moveRight();
}
void QDesignerMenu::moveUp(bool ctrl)
@@ -1053,7 +1079,15 @@ void QDesignerMenu::slotShowSubMenuNow()
if ((menu->windowFlags() & Qt::Popup) != Qt::Popup)
menu->setWindowFlags(Qt::Popup);
const QRect g = actionGeometry(action);
- menu->move(mapToGlobal(g.topRight()));
+ if (layoutDirection() == Qt::LeftToRight) {
+ menu->move(mapToGlobal(g.topRight()));
+ } else {
+ // The position is not initially correct due to the unknown width,
+ // causing it to overlap a bit the first time it is invoked.
+ const QSize menuSize = menu->size();
+ QPoint point = g.topLeft() - QPoint(menu->width() + 10, 0);
+ menu->move(mapToGlobal(point));
+ }
menu->show();
menu->setFocus();
} else {
diff --git a/tools/designer/src/lib/shared/qdesigner_menu_p.h b/tools/designer/src/lib/shared/qdesigner_menu_p.h
index 55d8bcd58..93735e608 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_menu_p.h
@@ -181,6 +181,9 @@ protected:
void selectCurrentAction();
private:
+ bool hideSubMenuOnCursorKey();
+ bool showSubMenuOnCursorKey();
+
QPoint m_startPosition;
int m_currentIndex;
QAction *m_addItem;
diff --git a/tools/designer/src/lib/shared/qdesigner_menubar.cpp b/tools/designer/src/lib/shared/qdesigner_menubar.cpp
index b53bb8d0b..2b19142e5 100644
--- a/tools/designer/src/lib/shared/qdesigner_menubar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menubar.cpp
@@ -219,18 +219,12 @@ bool QDesignerMenuBar::handleKeyPressEvent(QWidget *, QKeyEvent *e)
case Qt::Key_Left:
e->accept();
- if (QApplication::layoutDirection() == Qt::LeftToRight)
- moveLeft(e->modifiers() & Qt::ControlModifier);
- else
- moveRight(e->modifiers() & Qt::ControlModifier);
+ moveLeft(e->modifiers() & Qt::ControlModifier);
return true;
case Qt::Key_Right:
e->accept();
- if (QApplication::layoutDirection() == Qt::LeftToRight)
- moveRight(e->modifiers() & Qt::ControlModifier);
- else
- moveLeft(e->modifiers() & Qt::ControlModifier);
+ moveRight(e->modifiers() & Qt::ControlModifier);
return true; // no update
case Qt::Key_Up:
@@ -741,28 +735,48 @@ int QDesignerMenuBar::realActionCount() const
return actions().count() - 1; // 1 fake actions
}
-void QDesignerMenuBar::moveLeft(bool ctrl)
+bool QDesignerMenuBar::dragging() const
{
- if (ctrl)
- (void) swap(m_currentIndex, m_currentIndex - 1);
-
- m_currentIndex = qMax(0, --m_currentIndex);
- // Always re-select, swapping destroys order
- updateCurrentAction(true);
+ return m_dragging;
}
-bool QDesignerMenuBar::dragging() const
+void QDesignerMenuBar::moveLeft(bool ctrl)
{
- return m_dragging;
+ if (layoutDirection() == Qt::LeftToRight) {
+ movePrevious(ctrl);
+ } else {
+ moveNext(ctrl);
+ }
}
void QDesignerMenuBar::moveRight(bool ctrl)
{
- if (ctrl)
- (void) swap(m_currentIndex + 1, m_currentIndex);
+ if (layoutDirection() == Qt::LeftToRight) {
+ moveNext(ctrl);
+ } else {
+ movePrevious(ctrl);
+ }
+}
+
+void QDesignerMenuBar::movePrevious(bool ctrl)
+{
+ const bool swapped = ctrl && swapActions(m_currentIndex, m_currentIndex - 1);
+ const int newIndex = qMax(0, m_currentIndex - 1);
+ // Always re-select, swapping destroys order
+ if (swapped || newIndex != m_currentIndex) {
+ m_currentIndex = newIndex;
+ updateCurrentAction(true);
+ }
+}
- m_currentIndex = qMin(actions().count() - 1, ++m_currentIndex);
- updateCurrentAction(!ctrl);
+void QDesignerMenuBar::moveNext(bool ctrl)
+{
+ const bool swapped = ctrl && swapActions(m_currentIndex + 1, m_currentIndex);
+ const int newIndex = qMin(actions().count() - 1, m_currentIndex + 1);
+ if (swapped || newIndex != m_currentIndex) {
+ m_currentIndex = newIndex;
+ updateCurrentAction(!ctrl);
+ }
}
void QDesignerMenuBar::moveUp()
@@ -869,7 +883,7 @@ QAction *QDesignerMenuBar::safeActionAt(int index) const
return actions().at(index);
}
-bool QDesignerMenuBar::swap(int a, int b)
+bool QDesignerMenuBar::swapActions(int a, int b)
{
const int left = qMin(a, b);
int right = qMax(a, b);
diff --git a/tools/designer/src/lib/shared/qdesigner_menubar_p.h b/tools/designer/src/lib/shared/qdesigner_menubar_p.h
index 97a655b8f..fb820e1c3 100644
--- a/tools/designer/src/lib/shared/qdesigner_menubar_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_menubar_p.h
@@ -155,10 +155,12 @@ protected:
QAction *safeActionAt(int index) const;
- bool swap(int a, int b);
+ bool swapActions(int a, int b);
private:
void updateCurrentAction(bool selectAction);
+ void movePrevious(bool ctrl);
+ void moveNext(bool ctrl);
QAction *m_addMenu;
QPointer<QMenu> m_activeMenu;
diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
index 269345241..8c0c61d02 100644
--- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
@@ -466,7 +466,7 @@ QRect ToolBarEventFilter::freeArea(const QToolBar *tb)
QRect exclusionRectangle = actionList.empty() ? handleArea(tb) : tb->actionGeometry(actionList.back());
switch (tb->orientation()) {
case Qt::Horizontal:
- switch (QApplication::layoutDirection()) {
+ switch (tb->layoutDirection()) {
case Qt::LeftToRight:
rc.setX(exclusionRectangle.right() + 1);
break;
diff --git a/tools/designer/src/lib/shared/qtresourceview.cpp b/tools/designer/src/lib/shared/qtresourceview.cpp
index 40be3e60e..f55f7ae7b 100644
--- a/tools/designer/src/lib/shared/qtresourceview.cpp
+++ b/tools/designer/src/lib/shared/qtresourceview.cpp
@@ -582,17 +582,21 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare
{
d_ptr->q_ptr = this;
- d_ptr->m_editResourcesAction = new QAction(qdesigner_internal::createIconSet(QLatin1String("edit.png")), tr("Edit Resources..."), this);
+ QIcon editIcon = QIcon::fromTheme("document-properties", qdesigner_internal::createIconSet(QLatin1String("edit.png")));
+ d_ptr->m_editResourcesAction = new QAction(editIcon, tr("Edit Resources..."), this);
d_ptr->m_toolBar->addAction(d_ptr->m_editResourcesAction);
connect(d_ptr->m_editResourcesAction, SIGNAL(triggered()), this, SLOT(slotEditResources()));
d_ptr->m_editResourcesAction->setEnabled(false);
- d_ptr->m_reloadResourcesAction = new QAction(qdesigner_internal::createIconSet(QLatin1String("reload.png")), tr("Reload"), this);
+ QIcon refreshIcon = QIcon::fromTheme("view-refresh", qdesigner_internal::createIconSet(QLatin1String("reload.png")));
+ d_ptr->m_reloadResourcesAction = new QAction(refreshIcon, tr("Reload"), this);
+
d_ptr->m_toolBar->addAction(d_ptr->m_reloadResourcesAction);
connect(d_ptr->m_reloadResourcesAction, SIGNAL(triggered()), this, SLOT(slotReloadResources()));
d_ptr->m_reloadResourcesAction->setEnabled(false);
- d_ptr->m_copyResourcePathAction = new QAction(qdesigner_internal::createIconSet(QLatin1String("editcopy.png")), tr("Copy Path"), this);
+ QIcon copyIcon = QIcon::fromTheme("edit-copy", qdesigner_internal::createIconSet(QLatin1String("editcopy.png")));
+ d_ptr->m_copyResourcePathAction = new QAction(copyIcon, tr("Copy Path"), this);
connect(d_ptr->m_copyResourcePathAction, SIGNAL(triggered()), this, SLOT(slotCopyResourcePath()));
d_ptr->m_copyResourcePathAction->setEnabled(false);