Changeset 561 for trunk/tools/designer/src/lib/shared/qdesigner_menubar.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_menubar.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 ** … … 105 105 106 106 setAcceptDrops(true); // ### fake 107 108 107 109 108 110 m_addMenu->setText(tr("Type Here")); … … 220 222 case Qt::Key_Left: 221 223 e->accept(); 222 if (QApplication::layoutDirection() == Qt::LeftToRight) 223 moveLeft(e->modifiers() & Qt::ControlModifier); 224 else 225 moveRight(e->modifiers() & Qt::ControlModifier); 224 moveLeft(e->modifiers() & Qt::ControlModifier); 226 225 return true; 227 226 228 227 case Qt::Key_Right: 229 228 e->accept(); 230 if (QApplication::layoutDirection() == Qt::LeftToRight) 231 moveRight(e->modifiers() & Qt::ControlModifier); 232 else 233 moveLeft(e->modifiers() & Qt::ControlModifier); 229 moveRight(e->modifiers() & Qt::ControlModifier); 234 230 return true; // no update 235 231 … … 754 750 } 755 751 752 753 754 755 756 756 757 void QDesignerMenuBar::moveLeft(bool ctrl) 757 758 { 758 if (ctrl) 759 (void) swap(m_currentIndex, m_currentIndex - 1); 760 761 m_currentIndex = qMax(0, --m_currentIndex); 759 if (layoutDirection() == Qt::LeftToRight) { 760 movePrevious(ctrl); 761 } else { 762 moveNext(ctrl); 763 } 764 } 765 766 void QDesignerMenuBar::moveRight(bool ctrl) 767 { 768 if (layoutDirection() == Qt::LeftToRight) { 769 moveNext(ctrl); 770 } else { 771 movePrevious(ctrl); 772 } 773 } 774 775 void QDesignerMenuBar::movePrevious(bool ctrl) 776 { 777 const bool swapped = ctrl && swapActions(m_currentIndex, m_currentIndex - 1); 778 const int newIndex = qMax(0, m_currentIndex - 1); 762 779 // Always re-select, swapping destroys order 763 updateCurrentAction(true); 764 } 765 766 bool QDesignerMenuBar::dragging() const 767 { 768 return m_dragging; 769 } 770 771 void QDesignerMenuBar::moveRight(bool ctrl) 772 { 773 if (ctrl) 774 (void) swap(m_currentIndex + 1, m_currentIndex); 775 776 m_currentIndex = qMin(actions().count() - 1, ++m_currentIndex); 777 updateCurrentAction(!ctrl); 780 if (swapped || newIndex != m_currentIndex) { 781 m_currentIndex = newIndex; 782 updateCurrentAction(true); 783 } 784 } 785 786 void QDesignerMenuBar::moveNext(bool ctrl) 787 { 788 const bool swapped = ctrl && swapActions(m_currentIndex + 1, m_currentIndex); 789 const int newIndex = qMin(actions().count() - 1, m_currentIndex + 1); 790 if (swapped || newIndex != m_currentIndex) { 791 m_currentIndex = newIndex; 792 updateCurrentAction(!ctrl); 793 } 778 794 } 779 795 … … 864 880 menu->setWindowFlags(Qt::Popup); 865 881 menu->adjustSize(); 866 menu->move(mapToGlobal(g.bottomLeft())); 882 if (layoutDirection() == Qt::LeftToRight) { 883 menu->move(mapToGlobal(g.bottomLeft())); 884 } else { 885 // The position is not initially correct due to the unknown width, 886 // causing it to overlap a bit the first time it is invoked. 887 const QSize menuSize = menu->size(); 888 QPoint point = g.bottomRight() - QPoint(menu->width(), 0); 889 menu->move(mapToGlobal(point)); 890 } 867 891 menu->setFocus(Qt::MouseFocusReason); 868 892 menu->raise(); … … 882 906 } 883 907 884 bool QDesignerMenuBar::swap (int a, int b)908 bool QDesignerMenuBar::swap(int a, int b) 885 909 { 886 910 const int left = qMin(a, b);
Note:
See TracChangeset
for help on using the changeset viewer.