Changeset 561 for trunk/tools/designer/src/lib/shared/qdesigner_menu.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/designer/src/lib/shared/qdesigner_menu.cpp
r372 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the Qt Designer of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 73 73 74 74 using namespace qdesigner_internal; 75 76 77 78 79 80 81 82 83 84 85 86 87 75 88 76 89 QDesignerMenu::QDesignerMenu(QWidget *parent) : … … 332 345 if (action->menu() || hasSubMenuPixmap(action)) { 333 346 pm_rect = subMenuPixmapRect(action); 334 pm_rect.setLeft(pm_rect.left() - 20); // give the user a little more 335 // space to click 347 extendClickableArea(&pm_rect, layoutDirection()); 336 348 } 337 349 … … 388 400 QAction *action = safeActionAt(index); 389 401 QRect pm_rect = subMenuPixmapRect(action); 390 pm_rect.setLeft(pm_rect.left() - 20); // give the user a little more space to click402 391 403 392 404 const int old_index = m_currentIndex; … … 547 559 static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png")); 548 560 const QRect g = actionGeometry(action); 549 const int x = g.right() - pm.width() -2;561 const int x = 2; 550 562 const int y = g.top() + (g.height() - pm.height())/2 + 1; 551 563 return QRect(x, y, pm.width(), pm.height()); … … 876 888 } 877 889 878 void QDesignerMenu::moveLeft() 890 // Close submenu using the left/right keys according to layoutDirection(). 891 // Return false to indicate the event must be propagated to the menu bar. 892 bool QDesignerMenu::hideSubMenuOnCursorKey() 879 893 { 880 894 if (parentMenu()) { 881 895 hide(); 882 } else { 896 return true; 897 } 898 closeMenuChain(); 899 update(); 900 if (parentMenuBar()) 901 return false; 902 return true; 903 } 904 905 // Open a submenu using the left/right keys according to layoutDirection(). 906 // Return false to indicate the event must be propagated to the menu bar. 907 bool QDesignerMenu::showSubMenuOnCursorKey() 908 { 909 const QAction *action = currentAction(); 910 911 if (qobject_cast<const SpecialMenuAction*>(action) || action->isSeparator()) { 883 912 closeMenuChain(); 884 if (QDesignerMenuBar *mb = parentMenuBar()) { 885 if (QApplication::layoutDirection() == Qt::LeftToRight) 886 mb->moveLeft(); 887 else 888 mb->moveRight(); 889 } 890 } 891 update(); 913 if (parentMenuBar()) 914 return false; 915 return true; 916 } 917 m_lastSubMenuIndex = -1; // force a refresh 918 slotShowSubMenuNow(); 919 return true; 920 } 921 922 void QDesignerMenu::moveLeft() 923 { 924 const bool handled = layoutDirection() == Qt::LeftToRight ? 925 hideSubMenuOnCursorKey() : showSubMenuOnCursorKey(); 926 if (!handled) 927 parentMenuBar()->moveLeft(); 892 928 } 893 929 894 930 void QDesignerMenu::moveRight() 895 931 { 896 QAction *action = currentAction(); 897 898 if (qobject_cast<SpecialMenuAction*>(action) || action->isSeparator()) { 899 closeMenuChain(); 900 if (QDesignerMenuBar *mb = parentMenuBar()) { 901 if (QApplication::layoutDirection() == Qt::LeftToRight) 902 mb->moveRight(); 903 else 904 mb->moveLeft(); 905 } 906 } else { 907 m_lastSubMenuIndex = -1; // force a refresh 908 slotShowSubMenuNow(); 909 } 932 const bool handled = layoutDirection() == Qt::LeftToRight ? 933 showSubMenuOnCursorKey() : hideSubMenuOnCursorKey(); 934 if (!handled) 935 parentMenuBar()->moveRight(); 910 936 } 911 937 … … 1066 1092 menu->setWindowFlags(Qt::Popup); 1067 1093 const QRect g = actionGeometry(action); 1068 menu->move(mapToGlobal(g.topRight())); 1094 if (layoutDirection() == Qt::LeftToRight) { 1095 menu->move(mapToGlobal(g.topRight())); 1096 } else { 1097 // The position is not initially correct due to the unknown width, 1098 // causing it to overlap a bit the first time it is invoked. 1099 const QSize menuSize = menu->size(); 1100 QPoint point = g.topLeft() - QPoint(menu->width() + 10, 0); 1101 menu->move(mapToGlobal(point)); 1102 } 1069 1103 menu->show(); 1070 1104 menu->setFocus();
Note:
See TracChangeset
for help on using the changeset viewer.