summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qdockarealayout.cpp17
-rw-r--r--src/gui/widgets/qlineedit_p.cpp2
-rw-r--r--src/gui/widgets/qmainwindow.cpp25
-rw-r--r--src/gui/widgets/qmenu_p.h2
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp8
-rw-r--r--src/gui/widgets/qmenu_wince.cpp25
-rw-r--r--src/gui/widgets/qmenubar.cpp51
-rw-r--r--src/gui/widgets/qmenubar_p.h5
8 files changed, 85 insertions, 50 deletions
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index f44858a..806654c 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -1995,16 +1995,19 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
#ifdef QT_NO_TABBAR
const int tabBarShape = 0;
#endif
- QDockAreaLayoutInfo *info = new QDockAreaLayoutInfo(sep, dockPos, o,
- tabBarShape, mainWindow);
- QDockAreaLayoutItem item(info);
+ QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o,
+ tabBarShape, mainWindow));
stream >> item.pos >> item.size >> dummy >> dummy;
- if (!info->restoreState(stream, widgets, testing))
+ //we need to make sure the element is in the list so the dock widget can eventually be docked correctly
+ if (!testing)
+ item_list.append(item);
+
+ //here we need to make sure we change the item in the item_list
+ QDockAreaLayoutItem &lastItem = testing ? item : item_list.last();
+
+ if (!lastItem.subinfo->restoreState(stream, widgets, testing))
return false;
- if (!testing) {
- item_list.append(item);
- }
} else {
return false;
}
diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
index 2c76a5c..468c111 100644
--- a/src/gui/widgets/qlineedit_p.cpp
+++ b/src/gui/widgets/qlineedit_p.cpp
@@ -134,7 +134,7 @@ void QLineEditPrivate::_q_selectionChanged()
q->initStyleOption(&opt);
bool showCursor = control->hasSelectedText() ?
q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
- true;
+ q->hasFocus();
setCursorVisible(showCursor);
}
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index bf926f8..d2eda80 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -65,9 +65,6 @@ QT_BEGIN_NAMESPACE
extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
QT_END_NAMESPACE
#endif
-#ifdef QT_SOFTKEYS_ENABLED
-#include <private/qsoftkeymanager_p.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -80,9 +77,6 @@ public:
#ifdef Q_WS_MAC
, useHIToolBar(false)
#endif
-#ifdef QT_SOFTKEYS_ENABLED
- , menuBarAction(0)
-#endif
#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
, hasOldCursor(false) , cursorAdjusted(false)
#endif
@@ -94,9 +88,6 @@ public:
#ifdef Q_WS_MAC
bool useHIToolBar;
#endif
-#ifdef QT_SOFTKEYS_ENABLED
- QAction *menuBarAction;
-#endif
void init();
QList<int> hoverSeparator;
QPoint hoverPos;
@@ -117,10 +108,6 @@ void QMainWindowPrivate::init()
const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
iconSize = QSize(metric, metric);
q->setAttribute(Qt::WA_Hover);
-#ifdef QT_SOFTKEYS_ENABLED
- menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q);
- menuBarAction->setVisible(false);
-#endif
}
/*
@@ -492,13 +479,6 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
oldMenuBar->deleteLater();
}
d->layout->setMenuBar(menuBar);
-
-#ifdef QT_SOFTKEYS_ENABLED
- if (menuBar)
- addAction(d->menuBarAction);
- else
- removeAction(d->menuBarAction);
-#endif
}
/*!
@@ -1428,11 +1408,6 @@ bool QMainWindow::event(QEvent *event)
}
break;
#endif
-#ifdef QT_SOFTKEYS_ENABLED
- case QEvent::LanguageChange:
- d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey));
- break;
-#endif
default:
break;
}
diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
index 276ffe6..39cbbd8 100644
--- a/src/gui/widgets/qmenu_p.h
+++ b/src/gui/widgets/qmenu_p.h
@@ -347,7 +347,7 @@ public:
void syncAction(QWceMenuAction *);
inline void syncAction(QAction *a) { syncAction(findAction(a)); }
void removeAction(QWceMenuAction *);
- void rebuild(bool reCreate = false);
+ void rebuild();
inline void removeAction(QAction *a) { removeAction(findAction(a)); }
inline QWceMenuAction *findAction(QAction *a) {
for(int i = 0; i < actionItems.size(); i++) {
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index e46688c..7224768 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -324,6 +324,14 @@ void QMenuBarPrivate::symbianDestroyMenuBar()
symbian_menubar = 0;
}
+void QMenuBarPrivate::reparentMenuBar(QWidget *oldParent, QWidget *newParent)
+{
+ if (menubars()->contains(oldParent)) {
+ QMenuBarPrivate *object = menubars()->take(oldParent);
+ menubars()->insert(newParent, object);
+ }
+}
+
QMenuBarPrivate::QSymbianMenuBarPrivate::QSymbianMenuBarPrivate(QMenuBarPrivate *menubar)
{
d = menubar;
diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp
index 28b6b8b..1577f0a 100644
--- a/src/gui/widgets/qmenu_wince.cpp
+++ b/src/gui/widgets/qmenu_wince.cpp
@@ -101,7 +101,6 @@ struct qt_SHMENUBARINFO
COLORREF clrBk;
};
-typedef int (WINAPI *superfunc)(int, int);
typedef BOOL (WINAPI *AygCreateMenuBar)(qt_SHMENUBARINFO*);
typedef HRESULT (WINAPI *AygEnableSoftKey)(HWND,UINT,BOOL,BOOL);
@@ -254,6 +253,12 @@ static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool create
}
}
+// Removes all items from the menu without destroying the handles.
+static void qt_wce_clear_menu(HMENU hMenu)
+{
+ while (RemoveMenu(hMenu, 0, MF_BYPOSITION));
+}
+
/*!
\internal
@@ -404,7 +409,8 @@ QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() {
QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() {
qt_wce_delete_action_list(&actionItems);
- menuHandle = 0;
+ if (menuHandle)
+ DestroyMenu(menuHandle);
}
void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) {
@@ -439,14 +445,17 @@ HMENU QMenuPrivate::wceMenu(bool create) {
if (!wce_menu)
wce_menu = new QWceMenuPrivate;
if (!wce_menu->menuHandle || create)
- wce_menu->rebuild(create);
+ wce_menu->rebuild();
return wce_menu->menuHandle;
}
-void QMenuPrivate::QWceMenuPrivate::rebuild(bool reCreate) {
- if (menuHandle && !reCreate)
- DestroyMenu(menuHandle);
- menuHandle = CreatePopupMenu();
+void QMenuPrivate::QWceMenuPrivate::rebuild()
+{
+ if (!menuHandle)
+ menuHandle = CreatePopupMenu();
+ else
+ qt_wce_clear_menu(menuHandle);
+
for (int i = 0; i < actionItems.size(); ++i) {
QWceMenuAction *action = actionItems.at(i);
action->menuHandle = menuHandle;
@@ -522,6 +531,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() {
resourceHandle = IDR_MAIN_MENU5;
}
Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted");
+ qt_wce_clear_menu(menuHandle);
DestroyWindow(menubarHandle);
menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), resourceHandle);
Q_ASSERT_X(menubarHandle, "rebuild classic menu", "cannot create menubar from resource");
@@ -563,6 +573,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() {
leftButtonIsMenu = (leftButtonAction && leftButtonAction->menu());
Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted");
+ qt_wce_clear_menu(menuHandle);
DestroyWindow(menubarHandle);
if (leftButtonIsMenu) {
menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), IDR_MAIN_MENU2);
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index 9caadb7..13aa02b 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -71,6 +71,10 @@
extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp
#endif
+#ifdef QT_SOFTKEYS_ENABLED
+#include <private/qsoftkeymanager_p.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QMenuBarExtension : public QToolButton
@@ -740,17 +744,14 @@ void QMenuBarPrivate::init()
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true);
}
#endif
-#ifdef Q_WS_S60
- symbianCreateMenuBar(q->parentWidget());
- if(symbian_menubar)
- q->hide();
-#endif
-
q->setBackgroundRole(QPalette::Button);
oldWindow = oldParent = 0;
#ifdef QT3_SUPPORT
doAutoResize = false;
#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ menuBarAction = 0;
+#endif
handleReparent();
q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q));
@@ -1384,10 +1385,38 @@ void QMenuBarPrivate::handleReparent()
wce_menubar->rebuild();
#endif
#ifdef Q_WS_S60
- if (symbian_menubar)
+
+ // Construct symbian_menubar when this code path is entered first time
+ // and when newParent != NULL
+ if (!symbian_menubar)
+ symbianCreateMenuBar(newParent);
+
+ // Reparent and rebuild menubar when parent is changed
+ if (symbian_menubar) {
+ if (oldParent != newParent)
+ reparentMenuBar(oldParent, newParent);
+ q->hide();
symbian_menubar->rebuild();
-#endif
+ }
+#ifdef QT_SOFTKEYS_ENABLED
+ // Constuct menuBarAction when this code path is entered first time
+ if (!menuBarAction) {
+ if (newParent) {
+ menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, newParent);
+ menuBarAction->setVisible(false);
+ newParent->addAction(menuBarAction);
+ }
+ } else {
+ // If reparenting i.e. we already have menuBarAction, remove it from old parent
+ // and add for a new parent
+ if (oldParent)
+ oldParent->removeAction(menuBarAction);
+ if (newParent)
+ newParent->addAction(menuBarAction);
+ }
+#endif // QT_SOFTKEYS_ENABLED
+#endif // Q_WS_S60
}
#ifdef QT3_SUPPORT
@@ -1440,7 +1469,13 @@ void QMenuBar::changeEvent(QEvent *e)
|| e->type() == QEvent::ApplicationFontChange) {
d->itemsDirty = true;
d->updateGeometries();
+#ifdef QT_SOFTKEYS_ENABLED
+ } else if (e->type() == QEvent::LanguageChange) {
+ if (d->menuBarAction)
+ d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey));
+#endif
}
+
QWidget::changeEvent(e);
}
diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h
index 819aee4..82070fe 100644
--- a/src/gui/widgets/qmenubar_p.h
+++ b/src/gui/widgets/qmenubar_p.h
@@ -244,6 +244,7 @@ public:
#ifdef Q_WS_S60
void symbianCreateMenuBar(QWidget *);
void symbianDestroyMenuBar();
+ void reparentMenuBar(QWidget *oldParent, QWidget *newParent);
struct QSymbianMenuBarPrivate {
QList<QSymbianMenuAction*> actionItems;
QMenuBarPrivate *d;
@@ -268,7 +269,9 @@ public:
} *symbian_menubar;
static int symbianCommands(int command);
-
+#ifdef QT_SOFTKEYS_ENABLED
+ QAction *menuBarAction;
+#endif
#endif
};
#endif