diff options
Diffstat (limited to 'src/gui/widgets')
24 files changed, 258 insertions, 163 deletions
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp index 330a7f8..61ed0ea 100644 --- a/src/gui/widgets/qabstractbutton.cpp +++ b/src/gui/widgets/qabstractbutton.cpp @@ -1248,15 +1248,6 @@ void QAbstractButton::timerEvent(QTimerEvent *e) } } -#if defined(Q_OS_WINCE) && !defined(QT_NO_CONTEXTMENU) -/*! \reimp */ -void QAbstractButton::contextMenuEvent(QContextMenuEvent *e) -{ - e->ignore(); - setDown(false); -} -#endif - /*! \reimp */ void QAbstractButton::focusInEvent(QFocusEvent *e) { diff --git a/src/gui/widgets/qabstractbutton.h b/src/gui/widgets/qabstractbutton.h index 6503a56..f0cbb05 100644 --- a/src/gui/widgets/qabstractbutton.h +++ b/src/gui/widgets/qabstractbutton.h @@ -143,9 +143,6 @@ protected: void focusOutEvent(QFocusEvent *e); void changeEvent(QEvent *e); void timerEvent(QTimerEvent *e); -#ifdef Q_OS_WINCE - void contextMenuEvent(QContextMenuEvent *e); -#endif #ifdef QT3_SUPPORT public: diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm index c5977e4..6434289 100644 --- a/src/gui/widgets/qcocoamenu_mac.mm +++ b/src/gui/widgets/qcocoamenu_mac.mm @@ -1,11 +1,11 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) - ** - ** This file is part of the QtGui module of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the QtGui module 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 @@ -36,11 +36,11 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ #include "qmacdefines_mac.h" #include "qapplication.h" @@ -55,6 +55,16 @@ QT_FORWARD_DECLARE_CLASS(QAction) QT_FORWARD_DECLARE_CLASS(QWidget) QT_FORWARD_DECLARE_CLASS(QApplication) +QT_FORWARD_DECLARE_CLASS(QCoreApplication) +QT_FORWARD_DECLARE_CLASS(QApplicationPrivate) +QT_FORWARD_DECLARE_CLASS(QKeyEvent) +QT_FORWARD_DECLARE_CLASS(QEvent) + +QT_BEGIN_NAMESPACE +extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); //qapplication.cpp +QT_END_NAMESPACE + +QT_USE_NAMESPACE @implementation QT_MANGLE_NAMESPACE(QCocoaMenu) @@ -130,8 +140,9 @@ QT_FORWARD_DECLARE_CLASS(QApplication) // If it does, then we will first send the key sequence to the QWidget that has focus // since (in Qt's eyes) it needs to a chance at the key event first. If the widget // accepts the key event, we then return YES, but set the target and action to be nil, - // which means that the action should not be triggered. In every other case we return - // NO, which means that Cocoa can do as it pleases (i.e., fire the menu action). + // which means that the action should not be triggered, and instead dispatch the event ourselves. + // In every other case we return NO, which means that Cocoa can do as it pleases + // (i.e., fire the menu action). NSMenuItem *whichItem; if ([self hasShortcut:menu forKey:[event characters] @@ -154,9 +165,11 @@ QT_FORWARD_DECLARE_CLASS(QApplication) accel_ev.ignore(); qt_sendSpontaneousEvent(widget, &accel_ev); if (accel_ev.isAccepted()) { - *target = nil; - *action = nil; - return YES; + if (qt_dispatchKeyEvent(event, widget)) { + *target = nil; + *action = nil; + return YES; + } } } } diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 8c8e231..e9884bb 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -61,6 +61,7 @@ #endif #include <private/qcombobox_p.h> #include <private/qabstractitemmodel_p.h> +#include <private/qabstractscrollarea_p.h> #include <qdebug.h> #ifdef Q_WS_X11 @@ -108,7 +109,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt const QModelIndex &index) const { QStyleOptionMenuItem menuOption; - menuOption.palette = QComboBoxPrivate::viewContainerPalette(mCombo).resolve(QApplication::palette("QMenu")); + menuOption.palette = option.palette.resolve(QApplication::palette("QMenu")); menuOption.state = QStyle::State_None; if (mCombo->window()->isActiveWindow()) menuOption.state = QStyle::State_Active; @@ -2274,7 +2275,6 @@ void QComboBox::showPopup() bool boundToScreen = !window()->testAttribute(Qt::WA_DontShowOnScreen); const bool usePopup = style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this); - { int listHeight = 0; int count = 0; @@ -2306,11 +2306,23 @@ void QComboBox::showPopup() listRect.setHeight(listHeight); } - // add the frame size to the height. (+the spacing for the top and the bottom item) - int marginTop, marginBottom; - view()->getContentsMargins(0, &marginTop, 0, &marginBottom); - listRect.setHeight(listRect.height() + 2*container->spacing() - + marginTop + marginBottom); + { + // add the spacing for the grid on the top and the bottom; + int heightMargin = 2*container->spacing(); + + // add the frame of the container + int marginTop, marginBottom; + container->getContentsMargins(0, &marginTop, 0, &marginBottom); + heightMargin += marginTop + marginBottom; + + //add the frame of the view + view()->getContentsMargins(0, &marginTop, 0, &marginBottom); + marginTop += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top; + marginBottom += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom; + heightMargin += marginTop + marginBottom; + + listRect.setHeight(listRect.height() + heightMargin); + } // Add space for margin at top and bottom if the style wants it. if (usePopup) diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index f1203dc..c39a231 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -265,7 +265,7 @@ protected: const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionMenuItem opt = getStyleOption(option, index); - painter->eraseRect(option.rect); + painter->fillRect(option.rect, opt.palette.background()); mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo); } QSize sizeHint(const QStyleOptionViewItem &option, diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index 246da95..4a95292 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -752,7 +752,8 @@ QDialogButtonBox::~QDialogButtonBox() \value KdeLayout Use a policy appropriate for applications on KDE. \value GnomeLayout Use a policy appropriate for applications on GNOME. - The button layout is specified by the \l{style()}{current style}. + The button layout is specified by the \l{style()}{current style}. However, + on the X11 platform, it may be influenced by the desktop environment. */ /*! diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 9261c63..4f0ec1e 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -579,7 +579,7 @@ void QDockAreaLayoutInfo::fitItems() QLayoutStruct &ls = layout_struct_list[j++]; ls.init(); ls.empty = false; - if (gap || (item.flags & QDockAreaLayoutItem::KeepSize)) { + if (item.flags & QDockAreaLayoutItem::KeepSize) { ls.minimumSize = ls.maximumSize = ls.sizeHint = item.size; ls.expansive = false; ls.stretch = 0; diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 865b19c..a5be5f8 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -406,10 +406,14 @@ int QDockWidgetLayout::minimumTitleWidth() const QSize closeSize(0, 0); QSize floatSize(0, 0); - if (QLayoutItem *item = item_list[CloseButton]) - closeSize = item->sizeHint(); - if (QLayoutItem *item = item_list[FloatButton]) - floatSize = item->sizeHint(); + if (hasFeature(q, QDockWidget::DockWidgetClosable)) { + if (QLayoutItem *item = item_list[CloseButton]) + closeSize = item->widget()->sizeHint(); + } + if (hasFeature(q, QDockWidget::DockWidgetFloatable)) { + if (QLayoutItem *item = item_list[FloatButton]) + floatSize = item->widget()->sizeHint(); + } int titleHeight = this->titleHeight(); diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 8b553f9..fa337af 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -97,8 +97,7 @@ extern void qt_mac_secure_keyboard(bool); //qapplication_mac.cpp static inline bool shouldEnableInputMethod(QLineEdit *lineedit) { - const QLineEdit::EchoMode mode = lineedit->echoMode(); - return !lineedit->isReadOnly() && (mode == QLineEdit::Normal || mode == QLineEdit::PasswordEchoOnEdit); + return !lineedit->isReadOnly(); } /*! @@ -544,7 +543,13 @@ void QLineEdit::setEchoMode(EchoMode mode) Q_D(QLineEdit); if (mode == (EchoMode)d->echoMode) return; - setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); + Qt::InputMethodHints imHints = inputMethodHints(); + if (mode == Password) { + imHints |= Qt::ImhHiddenText; + } else { + imHints &= ~Qt::ImhHiddenText; + } + setInputMethodHints(imHints); d->echoMode = mode; d->passwordEchoEditing = false; d->updateTextLayout(); @@ -1768,6 +1773,13 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e) } } #endif + + if (e->button() == Qt::LeftButton && (!d->clickCausedFocus + || QApplication::autoSipOnMouseFocus())) { + QEvent event(QEvent::RequestSoftwareInputPanel); + QApplication::sendEvent(this, &event); + } + d->clickCausedFocus = 0; } /*! \reimp @@ -2350,6 +2362,8 @@ void QLineEdit::focusInEvent(QFocusEvent *e) d->moveCursor(d->nextMaskBlank(0)); else if (!d->hasSelectedText()) selectAll(); + } else if (e->reason() == Qt::MouseFocusReason) { + d->clickCausedFocus = 1; } #ifdef QT_KEYPAD_NAVIGATION if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)) diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h index 532528b..3db903f 100644 --- a/src/gui/widgets/qlineedit_p.h +++ b/src/gui/widgets/qlineedit_p.h @@ -76,7 +76,8 @@ public: : cursor(0), preeditCursor(0), cursorTimer(0), frame(1), cursorVisible(0), hideCursor(false), separator(0), readOnly(0), dragEnabled(0), contextMenuEnabled(1), echoMode(0), textDirty(0), - selDirty(0), validInput(1), alignment(Qt::AlignLeading | Qt::AlignVCenter), ascent(0), + selDirty(0), validInput(1), clickCausedFocus(0), + alignment(Qt::AlignLeading | Qt::AlignVCenter), ascent(0), maxLength(32767), hscroll(0), vscroll(0), lastCursorPos(-1), maskData(0), modifiedState(0), undoState(0), selstart(0), selend(0), userInput(false), emitingEditingFinished(false), passwordEchoEditing(false) @@ -110,6 +111,7 @@ public: uint textDirty : 1; uint selDirty : 1; uint validInput : 1; + uint clickCausedFocus : 1; uint alignment; int ascent; int maxLength; diff --git a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm b/src/gui/widgets/qmaccocoaviewcontainer_mac.mm index 710af6a..380e983 100644 --- a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/gui/widgets/qmaccocoaviewcontainer_mac.mm @@ -1,11 +1,11 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) - ** - ** This file is part of the QtGui module of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the QtGui module 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 @@ -36,11 +36,11 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ #import <Cocoa/Cocoa.h> #include <private/qwidget_p.h> diff --git a/src/gui/widgets/qmacnativewidget_mac.mm b/src/gui/widgets/qmacnativewidget_mac.mm index 1bc0430..0f4edf9 100644 --- a/src/gui/widgets/qmacnativewidget_mac.mm +++ b/src/gui/widgets/qmacnativewidget_mac.mm @@ -1,11 +1,11 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) - ** - ** This file is part of the QtGui module of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the QtGui module 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 @@ -36,11 +36,11 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ #import <Cocoa/Cocoa.h> #import <private/qcocoaview_mac_p.h> diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 46d6471..502c1e9 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -480,9 +480,6 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) oldMenuBar->hide(); oldMenuBar->deleteLater(); } -#ifdef Q_OS_WINCE - if (menuBar->size().height() > 0) -#endif d->layout->setMenuBar(menuBar); } diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 768446e..eade633 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1542,8 +1542,8 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) if (!previousPath.isEmpty()) layoutState.remove(previousPath); + pluggingWidget = widget; if (dockOptions & QMainWindow::AnimatedDocks) { - pluggingWidget = widget; QRect globalRect = currentGapRect; globalRect.moveTopLeft(parentWidget()->mapToGlobal(globalRect.topLeft())); #ifndef QT_NO_DOCKWIDGET @@ -1575,6 +1575,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) #endif currentGapPos.clear(); updateGapIndicator(); + pluggingWidget = 0; } return true; diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm index 950f758..c807afb 100644 --- a/src/gui/widgets/qmainwindowlayout_mac.mm +++ b/src/gui/widgets/qmainwindowlayout_mac.mm @@ -1,3 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + #include <private/qmainwindowlayout_p.h> #include <qtoolbar.h> #include <private/qtoolbarlayout_p.h> diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index b64a614..6be0f19 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -2916,8 +2916,8 @@ void QMenu::internalDelayedPopup() int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); const QRect actionRect(d->actionRect(d->currentAction)); const QSize menuSize(d->activeMenu->sizeHint()); - const QPoint rightPos(mapToGlobal(QPoint(rect().right() + subMenuOffset + 1, actionRect.top()))); - const QPoint leftPos(mapToGlobal(QPoint(rect().left() - subMenuOffset - menuSize.width(), actionRect.top()))); + const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); + const QPoint leftPos(mapToGlobal(QPoint(actionRect.left() - subMenuOffset - menuSize.width(), actionRect.top()))); QPoint pos(rightPos); QMenu *caused = qobject_cast<QMenu*>(d->activeMenu->d_func()->causedPopup.widget); diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 37c5fdb..47154e8 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -33,7 +33,7 @@ QT_BEGIN_NAMESPACE // ### FIX/Document this, we need some safe range of menu id's for Qt that don't clash with AIW ones #define QT_FIRST_MENU_ITEM 32000 -static QMenuBarPrivate *s60_menubar=0; +static QList<QMenuBarPrivate *> s60_menubars; struct SymbianMenuItem { @@ -167,7 +167,7 @@ static void setSoftkeys() { CEikButtonGroupContainer* cba = CEikonEnv::Static()->AppUiFactory()->Cba(); if (cba){ - if (s60_menubar) + if (s60_menubars.count()>0) cba->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT); else cba->SetCommandSetL(R_AVKON_SOFTKEYS_EXIT); @@ -178,11 +178,11 @@ static void rebuildMenu() { qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; deleteAll( &symbianMenus ); - if (!s60_menubar) + if (s60_menubars.count()==0) return; - for (int i = 0; i < s60_menubar->actions.size(); ++i) { + for (int i = 0; i < s60_menubars.last()->actions.size(); ++i) { QSymbianMenuAction *symbianActionTopLevel = new QSymbianMenuAction; - symbianActionTopLevel->action = s60_menubar->actions.at(i); + symbianActionTopLevel->action = s60_menubars.last()->actions.at(i); symbianActionTopLevel->parent = 0; symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++; qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus); @@ -193,7 +193,7 @@ static void rebuildMenu() Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane) { - if (!s60_menubar) + if (s60_menubars.count()==0) return; rebuildMenu(); for (int i = 0; i < symbianMenus.count(); ++i) @@ -261,15 +261,17 @@ void QMenuBarPrivate::symbianDestroyMenuBar() Q_Q(QMenuBar); int index = nativeMenuBars.indexOf(q); nativeMenuBars.removeAt(index); + s60_menubars.removeLast(); + rebuildMenu(); if (symbian_menubar) - delete symbian_menubar; + delete symbian_menubar; symbian_menubar = 0; } QMenuBarPrivate::QSymbianMenuBarPrivate::QSymbianMenuBarPrivate(QMenuBarPrivate *menubar) { d = menubar; - s60_menubar = menubar; + s60_menubars.append(menubar); } QMenuBarPrivate::QSymbianMenuBarPrivate::~QSymbianMenuBarPrivate() @@ -277,7 +279,7 @@ QMenuBarPrivate::QSymbianMenuBarPrivate::~QSymbianMenuBarPrivate() deleteAll( &symbianMenus ); symbianMenus.clear(); d = 0; - s60_menubar = 0; + rebuild(); } QMenuPrivate::QSymbianMenuPrivate::QSymbianMenuPrivate() @@ -362,7 +364,7 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::removeAction(QSymbianMenuAction *a void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild() { setSoftkeys(); - if (!s60_menubar) + if (s60_menubars.count()==0) return; rebuildMenu(); diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index ea58d46..847a623 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -58,6 +58,9 @@ #include <QtCore/qlibrary.h> #include <commctrl.h> +#if Q_OS_WINCE_WM +# include <windowsm.h> +#endif #include "qguifunctions_wince.h" @@ -71,6 +74,12 @@ #define SHCMBM_GETSUBMENU (WM_USER + 401) #endif +#ifdef Q_OS_WINCE_WM +# define SHMBOF_NODEFAULT 0x00000001 +# define SHMBOF_NOTIFY 0x00000002 +# define SHCMBM_OVERRIDEKEY (WM_USER + 0x193) +#endif + extern bool qt_wince_is_smartphone();//defined in qguifunctions_wce.cpp extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wce.cpp @@ -204,8 +213,13 @@ static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, i mbi.dwFlags = flags; mbi.nToolBarId = toolbarID; - if (ptrCreateMenuBar(&mbi)) + if (ptrCreateMenuBar(&mbi)) { + // Tell the menu bar that we want to override hot key behaviour. + LPARAM lparam = MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, + SHMBOF_NODEFAULT | SHMBOF_NOTIFY); + SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, lparam); return mbi.hwndMB; + } } return 0; } diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index b92f48b..b6ce76b 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1045,6 +1045,12 @@ void QMenuBar::setVisible(bool visible) if(d->wce_menubar) return; #endif +#ifdef Q_OS_SYMBIAN + Q_D(QMenuBar); + if(d->symbian_menubar) + return; +#endif + QWidget::setVisible(visible); } diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 2e9201d..e563fa1 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -624,7 +624,7 @@ void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx) if (viewport->updatesEnabled() && viewport->isVisible()) { int dy = 0; - if (doc->findBlockByLineNumber(control->topBlock).isValid()) { + if (doc->findBlockByNumber(control->topBlock).isValid()) { dy = (int)(-q->blockBoundingGeometry(block).y()) + verticalOffset() - verticalOffset(blockNumber, lineNumber); } diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 7d970ad..69221ba 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -131,7 +131,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const option->state &= ~QStyle::State_Enabled; if (isActiveWindow()) option->state |= QStyle::State_Active; - if (option->rect == d->hoverRect) + if (!d->dragInProgress && option->rect == d->hoverRect) option->state |= QStyle::State_MouseOver; option->shape = d->shape; option->text = tab.text; @@ -454,9 +454,6 @@ void QTabBarPrivate::layoutTabs() maxExtent = maxWidth; } - if (pressedIndex != -1 && movable) - grabCache(0, tabList.count(), true); - Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure. // Mirror our front item. tabChain[tabChainIndex].init(); @@ -1088,7 +1085,7 @@ void QTabBar::setTabData(int index, const QVariant & data) } /*! - Returns the datad of the tab at position \a index, or a null + Returns the data of the tab at position \a index, or a null variant if \a index is out of range. */ QVariant QTabBar::tabData(int index) const @@ -1170,13 +1167,13 @@ void QTabBar::setCurrentIndex(int index) d->currentIndex = index; update(); d->makeVisible(index); + d->tabList[index].lastTab = oldIndex; + d->layoutWidgets(oldIndex); + d->layoutWidgets(index); #ifdef QT3_SUPPORT emit selected(index); #endif emit currentChanged(index); - d->tabList[index].lastTab = oldIndex; - d->layoutWidgets(oldIndex); - d->layoutWidgets(index); } } @@ -1484,6 +1481,8 @@ void QTabBar::paintEvent(QPaintEvent *) bool vertical = verticalTabs(d->shape); QStyleOptionTab cutTab; selected = d->currentIndex; + if (d->dragInProgress) + selected = d->pressedIndex; for (int i = 0; i < d->tabList.count(); ++i) optTabBase.tabBarRect |= tabRect(i); @@ -1522,11 +1521,7 @@ void QTabBar::paintEvent(QPaintEvent *) if (i == selected) continue; - if (!d->tabList[i].animatingCache.isNull() && d->paintWithOffsets) { - p.drawPixmap(tab.rect, d->tabList[i].animatingCache); - } else { - p.drawControl(QStyle::CE_TabBarTab, tab); - } + p.drawControl(QStyle::CE_TabBarTab, tab); } // Draw the selected tab last to get it "on top" @@ -1539,7 +1534,11 @@ void QTabBar::paintEvent(QPaintEvent *) else tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset); } - p.drawControl(QStyle::CE_TabBarTab, tab); + if (!d->dragInProgress) + p.drawControl(QStyle::CE_TabBarTab, tab); + else + d->movingTab->setGeometry(tab.rect); + } // Only draw the tear indicator if necessary. Most of the time we don't need too. @@ -1680,6 +1679,7 @@ void QTabBarPrivate::_q_moveTab(int offset) if (!validIndex(index)) return; tabList[index].dragOffset = offset; + layoutTab(index); // Make buttons follow tab q->update(); } } @@ -1727,8 +1727,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event) if (!d->dragInProgress && d->pressedIndex != -1) { if ((event->pos() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()) { d->dragInProgress = true; - if (d->animations.isEmpty()) - d->grabCache(0, d->tabList.count(), false); + d->setupMovableTab(); } } @@ -1773,7 +1772,6 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event) if (dragDistance > needsToBeOver) d->slide(i + offset, d->pressedIndex); } - } // Buttons needs to follow the dragged tab d->layoutTab(d->pressedIndex); @@ -1801,32 +1799,41 @@ void QTabBarPrivate::_q_moveTabFinished() } } -void QTabBarPrivate::grabCache(int start, int end, bool unhide) +void QTabBarPrivate::setupMovableTab() { Q_Q(QTabBar); - paintWithOffsets = false; - bool showButtonsAgain = rightB->isVisible(); - rightB->hide(); - leftB->hide(); - - QWidget *topLevel = q->window(); - QPoint topLevelOffset(q->mapTo(topLevel, QPoint())); - for (int i = start; i < end; ++i) { - QRect tabRect = q->tabRect(i); - tabRect.translate(topLevelOffset); - if (unhide) { - tabList[i].unHideWidgets(); - layoutWidgets(i); - } - tabList[i].animatingCache = QPixmap::grabWidget(topLevel, tabRect); - if (i != pressedIndex) - tabList[i].hideWidgets(); - } - if (showButtonsAgain) { - rightB->show(); - leftB->show(); - } - paintWithOffsets = true; + if (!movingTab) + movingTab = new QWidget(q); + + QRect grabRect = q->tabRect(pressedIndex); + + QPixmap grabImage(grabRect.size()); + grabImage.fill(Qt::transparent); + QStylePainter p(&grabImage, q); + + QStyleOptionTabV3 tab; + q->initStyleOption(&tab, pressedIndex); + tab.rect.moveTopLeft(QPoint(0, 0)); + p.drawControl(QStyle::CE_TabBarTab, tab); + p.end(); + + QPalette pal; + pal.setBrush(QPalette::All, QPalette::Window, grabImage); + movingTab->setPalette(pal); + movingTab->setGeometry(grabRect); + movingTab->setAutoFillBackground(true); + movingTab->raise(); + + // Re-arrange widget order to avoid overlaps + if (tabList[pressedIndex].leftWidget) + tabList[pressedIndex].leftWidget->raise(); + if (tabList[pressedIndex].rightWidget) + tabList[pressedIndex].rightWidget->raise(); + if (leftB) + leftB->raise(); + if (rightB) + rightB->raise(); + movingTab->setVisible(true); } void QTabBarPrivate::_q_moveTabFinished(int index) @@ -1834,10 +1841,9 @@ void QTabBarPrivate::_q_moveTabFinished(int index) Q_Q(QTabBar); bool cleanup = (pressedIndex == index) || (pressedIndex == -1) || !validIndex(index); if (animations.isEmpty() && cleanup) { + movingTab->setVisible(false); // We might not get a mouse release for (int i = 0; i < tabList.count(); ++i) { tabList[i].dragOffset = 0; - tabList[i].unHideWidgets(); - tabList[i].animatingCache = QPixmap(); } if (pressedIndex != -1 && movable) { pressedIndex = -1; @@ -1881,6 +1887,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event) d->_q_moveTabFinished(d->pressedIndex); } d->dragInProgress = false; + d->movingTab->setVisible(false); d->dragStartPosition = QPoint(); } @@ -2203,21 +2210,19 @@ void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget) widget->setParent(this); // make sure our left and right widgets stay on top widget->lower(); + widget->show(); } if (position == LeftSide) { if (d->tabList[index].leftWidget) d->tabList[index].leftWidget->hide(); d->tabList[index].leftWidget = widget; - if(!d->tabList[index].hidLeft && widget) - widget->show(); } else { if (d->tabList[index].rightWidget) d->tabList[index].rightWidget->hide(); d->tabList[index].rightWidget = widget; - if(!d->tabList[index].hidRight && widget) - widget->show(); } d->layoutTabs(); + d->refresh(); update(); } diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h index a117aa3..cb1a15b 100644 --- a/src/gui/widgets/qtabbar_p.h +++ b/src/gui/widgets/qtabbar_p.h @@ -70,7 +70,6 @@ QT_BEGIN_NAMESPACE - class QTabBarPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QTabBar) @@ -78,7 +77,7 @@ public: QTabBarPrivate() :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), - layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false) {} + layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), movingTab(0) {} int currentIndex; int pressedIndex; @@ -98,8 +97,6 @@ public: , lastTab(-1) , timeLine(0) , dragOffset(0) - , hidLeft(false) - , hidRight(false) {} bool enabled; int shortcutId; @@ -123,9 +120,6 @@ public: QTimeLine *timeLine; int dragOffset; - QPixmap animatingCache; - bool hidLeft; - bool hidRight; void makeTimeLine(QWidget *q) { if (timeLine) @@ -135,27 +129,6 @@ public: q->connect(timeLine, SIGNAL(finished()), q, SLOT(_q_moveTabFinished())); } - void hideWidgets() { - if (!hidRight && rightWidget) { - hidRight = rightWidget->isVisible(); - rightWidget->hide(); - } - - if (!hidLeft && leftWidget) { - hidLeft = leftWidget->isVisible(); - leftWidget->hide(); - } - } - - void unHideWidgets() { - if (leftWidget && hidLeft) - leftWidget->show(); - hidLeft = false; - if (rightWidget && hidRight) - rightWidget->show(); - hidRight = false; - } - }; QList<Tab> tabList; QHash<QTimeLine*, int> animations; @@ -184,12 +157,12 @@ public: void _q_moveTabFinished(int offset); QRect hoverRect; - void grabCache(int start, int end, bool unhide); void refresh(); void layoutTabs(); void layoutWidgets(int index = -1); void layoutTab(int index); void updateMacBorderMetrics(); + void setupMovableTab(); void makeVisible(int index); QSize iconSize; @@ -206,6 +179,8 @@ public: bool dragInProgress; bool documentMode; + QWidget *movingTab; + // shared by tabwidget and qtabbar static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size) { diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index b239e32..1c4df93 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -1478,7 +1478,13 @@ void QTextEditPrivate::paint(QPainter *p, QPaintEvent *e) layout->setViewport(QRect()); } -/*! \reimp +/*! \fn void QTextEdit::paintEvent(QPaintEvent *event) + +This event handler can be reimplemented in a subclass to receive paint events passed in \a event. +It is usually unnecessary to reimplement this function in a subclass of QTextEdit. + +\warning The underlying text document must not be modified from within a reimplementation +of this function. */ void QTextEdit::paintEvent(QPaintEvent *e) { diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 85d6ea2..1babb6d 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -1153,6 +1153,17 @@ bool QToolBar::event(QEvent *event) if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event))) return true; break; +#ifdef Q_OS_WINCE + case QEvent::ContextMenu: + { + QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event); + QWidget* child = childAt(contextMenuEvent->pos()); + QAbstractButton* button = qobject_cast<QAbstractButton*>(child); + if (button) + button->setDown(false); + } + break; +#endif case QEvent::Leave: if (d->state != 0 && d->state->dragging) { #ifdef Q_OS_WIN |