updated on Wed Jan 11 20:01:35 UTC 2012
[aur-mirror.git] / qt-ubuntu / kubuntu_15_appmenu.diff
blobf5fdf03b3f61bd8fda6caf513be3ff6c112111d9
1 appmenu-qt patch for Qt 4.7.3.
3 diff --git a/src/gui/widgets/qabstractplatformmenubar_p.h b/src/gui/widgets/qabstractplatformmenubar_p.h
4 new file mode 100644
5 index 0000000..cb4e5cb
6 --- /dev/null
7 +++ b/src/gui/widgets/qabstractplatformmenubar_p.h
8 @@ -0,0 +1,107 @@
9 +/****************************************************************************
10 +**
11 +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
12 +** All rights reserved.
13 +** Contact: Nokia Corporation (qt-info@nokia.com)
14 +**
15 +** This file is part of the QtGui module of the Qt Toolkit.
16 +**
17 +** $QT_BEGIN_LICENSE:LGPL$
18 +** No Commercial Usage
19 +** This file contains pre-release code and may not be distributed.
20 +** You may use this file in accordance with the terms and conditions
21 +** contained in the Technology Preview License Agreement accompanying
22 +** this package.
23 +**
24 +** GNU Lesser General Public License Usage
25 +** Alternatively, this file may be used under the terms of the GNU Lesser
26 +** General Public License version 2.1 as published by the Free Software
27 +** Foundation and appearing in the file LICENSE.LGPL included in the
28 +** packaging of this file. Please review the following information to
29 +** ensure the GNU Lesser General Public License version 2.1 requirements
30 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
31 +**
32 +** In addition, as a special exception, Nokia gives you certain additional
33 +** rights. These rights are described in the Nokia Qt LGPL Exception
34 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
35 +**
36 +** If you have questions regarding the use of this file, please contact
37 +** Nokia at qt-info@nokia.com.
38 +**
39 +**
40 +**
41 +**
42 +**
43 +**
44 +**
45 +**
46 +** $QT_END_LICENSE$
47 +**
48 +****************************************************************************/
49 +#ifndef QABSTRACTPLATFORMMENUBAR_P_H
50 +#define QABSTRACTPLATFORMMENUBAR_P_H
52 +#include <qfactoryinterface.h>
53 +#include <qglobal.h>
54 +#include <qplugin.h>
56 +#ifndef QT_NO_MENUBAR
58 +QT_BEGIN_NAMESPACE
60 +class QAction;
61 +class QActionEvent;
62 +class QEvent;
63 +class QMenuBar;
64 +class QObject;
65 +class QWidget;
67 +class QAbstractPlatformMenuBar;
69 +struct QPlatformMenuBarFactoryInterface : public QFactoryInterface
71 + virtual QAbstractPlatformMenuBar *create() = 0;
72 +};
74 +#define QPlatformMenuBarFactoryInterface_iid "com.nokia.qt.QPlatformMenuBarFactoryInterface"
75 +Q_DECLARE_INTERFACE(QPlatformMenuBarFactoryInterface, QPlatformMenuBarFactoryInterface_iid)
77 +/*!
78 + The platform-specific implementation of a menubar
79 +*/
80 +class QAbstractPlatformMenuBar
82 +public:
83 + virtual ~QAbstractPlatformMenuBar() {}
85 + virtual void init(QMenuBar *) = 0;
87 + virtual void setVisible(bool visible) = 0;
89 + virtual void actionEvent(QActionEvent *) = 0;
91 + virtual void handleReparent(QWidget *oldParent, QWidget *newParent, QWidget *oldWindow, QWidget *newWindow) = 0;
93 + virtual bool allowCornerWidgets() const = 0;
95 + virtual void popupAction(QAction *) = 0;
97 + virtual void setNativeMenuBar(bool) = 0;
99 + virtual bool isNativeMenuBar() const = 0;
101 + /*!
102 + Return true if the native menubar is capable of listening to the
103 + shortcut keys. If false is returned, QMenuBar will trigger actions on
104 + shortcut itself.
105 + */
106 + virtual bool shortcutsHandledByNativeMenuBar() const = 0;
108 + virtual bool menuBarEventFilter(QObject *, QEvent *event) = 0;
111 +QT_END_NAMESPACE
113 +#endif // QT_NO_MENUBAR
115 +#endif // QABSTRACTPLATFORMMENUBAR_P_H
116 diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
117 index 9f7b130..ef8c0bf 100644
118 --- a/src/gui/widgets/qmenu_mac.mm
119 +++ b/src/gui/widgets/qmenu_mac.mm
120 @@ -1643,7 +1643,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::~QMacMenuBarPrivate()
123 void
124 -QMenuBarPrivate::QMacMenuBarPrivate::addAction(QAction *a, QMacMenuAction *before)
125 +QMenuBarPrivate::QMacMenuBarPrivate::addAction(QAction *a, QAction *before)
127 if (a->isSeparator() || !menu)
128 return;
129 @@ -1653,7 +1653,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::addAction(QAction *a, QMacMenuAction *befor
130 #ifndef QT_MAC_USE_COCOA
131 action->command = qt_mac_menu_static_cmd_id++;
132 #endif
133 - addAction(action, before);
134 + addAction(action, findAction(before));
137 void
138 diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
139 index 809555d..6be7da9 100644
140 --- a/src/gui/widgets/qmenu_p.h
141 +++ b/src/gui/widgets/qmenu_p.h
142 @@ -154,6 +154,9 @@ public:
143 #endif
144 scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
145 hasCheckableItems(0), sloppyAction(0), doChildEffects(false)
146 +#ifdef QT3_SUPPORT
147 + ,emitHighlighted(false)
148 +#endif
149 #ifdef Q_WS_MAC
150 ,mac_menu(0)
151 #endif
152 @@ -163,9 +166,6 @@ public:
153 #ifdef Q_WS_S60
154 ,symbian_menu(0)
155 #endif
156 -#ifdef QT3_SUPPORT
157 - ,emitHighlighted(false)
158 -#endif
160 ~QMenuPrivate()
162 diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
163 index 2f9ada6..6fadc34 100644
164 --- a/src/gui/widgets/qmenu_symbian.cpp
165 +++ b/src/gui/widgets/qmenu_symbian.cpp
166 @@ -397,12 +397,12 @@ void QMenuPrivate::QSymbianMenuPrivate::rebuild(bool)
170 -void QMenuBarPrivate::QSymbianMenuBarPrivate::addAction(QAction *a, QSymbianMenuAction *before)
171 +void QMenuBarPrivate::QSymbianMenuBarPrivate::addAction(QAction *a, QAction *before)
173 QSymbianMenuAction *action = new QSymbianMenuAction;
174 action->action = a;
175 action->command = qt_symbian_menu_static_cmd_id++;
176 - addAction(action, before);
177 + addAction(action, findAction(before));
180 void QMenuBarPrivate::QSymbianMenuBarPrivate::addAction(QSymbianMenuAction *action, QSymbianMenuAction *before)
181 diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp
182 index 24df6a2..383820a 100644
183 --- a/src/gui/widgets/qmenu_wince.cpp
184 +++ b/src/gui/widgets/qmenu_wince.cpp
185 @@ -506,12 +506,12 @@ void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action)
186 rebuild();
189 -void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before)
190 +void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QAction *before)
192 QWceMenuAction *action = new QWceMenuAction;
193 action->action = a;
194 action->command = qt_wce_menu_static_cmd_id++;
195 - addAction(action, before);
196 + addAction(action, findAction(before));
199 void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before)
200 diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
201 index 6a41c74..4d42ac4 100644
202 --- a/src/gui/widgets/qmenubar.cpp
203 +++ b/src/gui/widgets/qmenubar.cpp
204 @@ -55,6 +55,9 @@
205 #include <qtoolbar.h>
206 #include <qtoolbutton.h>
207 #include <qwhatsthis.h>
208 +#ifdef Q_WS_X11
209 +#include <qpluginloader.h>
210 +#endif
212 #ifndef QT_NO_MENUBAR
214 @@ -66,6 +69,9 @@
215 #include "qmenu_p.h"
216 #include "qmenubar_p.h"
217 #include "qdebug.h"
218 +#ifdef Q_WS_X11
219 +#include "qmenubar_x11_p.h"
220 +#endif
222 #ifdef Q_WS_WINCE
223 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp
224 @@ -173,7 +179,11 @@ void QMenuBarPrivate::updateGeometries()
225 return;
226 int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2);
227 int q_start = -1;
228 - if(leftWidget || rightWidget) {
229 + if(
230 +#ifdef Q_WS_X11
231 + platformMenuBar->allowCornerWidgets() &&
232 +#endif
233 + (leftWidget || rightWidget)) {
234 int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q)
235 + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
236 int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q)
237 @@ -204,7 +214,11 @@ void QMenuBarPrivate::updateGeometries()
238 calcActionRects(q_width, q_start);
239 currentAction = 0;
240 #ifndef QT_NO_SHORTCUT
241 - if(itemsDirty) {
242 + if(
243 +#ifdef Q_WS_X11
244 + !platformMenuBar->shortcutsHandledByNativeMenuBar() &&
245 +#endif
246 + itemsDirty) {
247 for(int j = 0; j < shortcutIndexMap.size(); ++j)
248 q->releaseShortcut(shortcutIndexMap.value(j));
249 shortcutIndexMap.resize(0); // faster than clear
250 @@ -212,6 +226,12 @@ void QMenuBarPrivate::updateGeometries()
251 shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
253 #endif
254 +#ifdef Q_WS_X11
255 + if(q->isNativeMenuBar()) {//nothing to see here folks, move along..
256 + itemsDirty = false;
257 + return;
259 +#endif
260 itemsDirty = false;
262 hiddenActions.clear();
263 @@ -743,6 +763,11 @@ void QMenuBarPrivate::init()
264 QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true);
266 #endif
267 +#ifdef Q_WS_X11
268 + platformMenuBar = qt_guiPlatformMenuBarFactory()->create();
269 + platformMenuBar->init(q);
270 +#endif
272 q->setBackgroundRole(QPalette::Button);
273 oldWindow = oldParent = 0;
274 #ifdef QT3_SUPPORT
275 @@ -751,6 +776,10 @@ void QMenuBarPrivate::init()
276 #ifdef QT_SOFTKEYS_ENABLED
277 menuBarAction = 0;
278 #endif
279 +#ifdef Q_WS_X11
280 + cornerWidgetToolBar = 0;
281 + cornerWidgetContainer = 0;
282 +#endif
283 handleReparent();
284 q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q));
286 @@ -821,6 +850,10 @@ QMenuBar::~QMenuBar()
287 Q_D(QMenuBar);
288 d->symbianDestroyMenuBar();
289 #endif
290 +#ifdef Q_WS_X11
291 + Q_D(QMenuBar);
292 + delete d->cornerWidgetToolBar;
293 +#endif
297 @@ -1072,11 +1105,16 @@ void QMenuBar::paintEvent(QPaintEvent *e)
299 void QMenuBar::setVisible(bool visible)
301 +#ifdef Q_WS_X11
302 + Q_D(QMenuBar);
303 + d->platformMenuBar->setVisible(visible);
304 +#else
305 #if defined(Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60)
306 if (isNativeMenuBar())
307 return;
308 #endif
309 QWidget::setVisible(visible);
310 +#endif // Q_WS_X11
314 @@ -1272,6 +1310,9 @@ void QMenuBar::actionEvent(QActionEvent *e)
316 Q_D(QMenuBar);
317 d->itemsDirty = true;
318 +#ifdef Q_WS_X11
319 + d->platformMenuBar->actionEvent(e);
320 +#endif
321 #if defined (Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60)
322 if (isNativeMenuBar()) {
323 #ifdef Q_WS_MAC
324 @@ -1284,7 +1325,7 @@ void QMenuBar::actionEvent(QActionEvent *e)
325 if (!nativeMenuBar)
326 return;
327 if(e->type() == QEvent::ActionAdded)
328 - nativeMenuBar->addAction(e->action(), nativeMenuBar->findAction(e->before()));
329 + nativeMenuBar->addAction(e->action(), e->before());
330 else if(e->type() == QEvent::ActionRemoved)
331 nativeMenuBar->removeAction(e->action());
332 else if(e->type() == QEvent::ActionChanged)
333 @@ -1366,6 +1407,10 @@ void QMenuBarPrivate::handleReparent()
334 newWindow->installEventFilter(q);
337 +#ifdef Q_WS_X11
338 + platformMenuBar->handleReparent(oldParent, newParent, oldWindow, newWindow);
339 +#endif
341 oldParent = newParent;
342 oldWindow = newWindow;
344 @@ -1563,6 +1608,11 @@ bool QMenuBar::event(QEvent *e)
345 bool QMenuBar::eventFilter(QObject *object, QEvent *event)
347 Q_D(QMenuBar);
348 +#ifdef Q_WS_X11
349 + if (d->platformMenuBar->menuBarEventFilter(object, event)) {
350 + return true;
352 +#endif
353 if (object == parent() && object) {
354 #ifdef QT3_SUPPORT
355 if (d->doAutoResize && event->type() == QEvent::Resize) {
356 @@ -1656,7 +1706,7 @@ QRect QMenuBar::actionGeometry(QAction *act) const
357 QSize QMenuBar::minimumSizeHint() const
359 Q_D(const QMenuBar);
360 -#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60)
361 +#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) || defined(Q_WS_X11)
362 const bool as_gui_menubar = !isNativeMenuBar();
363 #else
364 const bool as_gui_menubar = true;
365 @@ -1679,6 +1729,9 @@ QSize QMenuBar::minimumSizeHint() const
366 ret += QSize(2*fw + hmargin, 2*fw + vmargin);
368 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
369 +#ifdef Q_WS_X11
370 + if (d->platformMenuBar->allowCornerWidgets()) {
371 +#endif
372 if(d->leftWidget) {
373 QSize sz = d->leftWidget->minimumSizeHint();
374 ret.setWidth(ret.width() + sz.width());
375 @@ -1691,6 +1744,9 @@ QSize QMenuBar::minimumSizeHint() const
376 if(sz.height() + margin > ret.height())
377 ret.setHeight(sz.height() + margin);
379 +#ifdef Q_WS_X11
381 +#endif
382 if(as_gui_menubar) {
383 QStyleOptionMenuItem opt;
384 opt.rect = rect();
385 @@ -1712,7 +1768,7 @@ QSize QMenuBar::minimumSizeHint() const
386 QSize QMenuBar::sizeHint() const
388 Q_D(const QMenuBar);
389 -#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60)
390 +#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) || defined(Q_WS_X11)
391 const bool as_gui_menubar = !isNativeMenuBar();
392 #else
393 const bool as_gui_menubar = true;
394 @@ -1738,6 +1794,9 @@ QSize QMenuBar::sizeHint() const
395 ret += QSize(fw + hmargin, fw + vmargin);
397 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
398 +#ifdef Q_WS_X11
399 + if(d->platformMenuBar->allowCornerWidgets()) {
400 +#endif
401 if(d->leftWidget) {
402 QSize sz = d->leftWidget->sizeHint();
403 ret.setWidth(ret.width() + sz.width());
404 @@ -1750,6 +1809,9 @@ QSize QMenuBar::sizeHint() const
405 if(sz.height() + margin > ret.height())
406 ret.setHeight(sz.height() + margin);
408 +#ifdef Q_WS_X11
410 +#endif
411 if(as_gui_menubar) {
412 QStyleOptionMenuItem opt;
413 opt.rect = rect();
414 @@ -1771,7 +1833,7 @@ QSize QMenuBar::sizeHint() const
415 int QMenuBar::heightForWidth(int) const
417 Q_D(const QMenuBar);
418 -#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60)
419 +#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) || defined(Q_WS_X11)
420 const bool as_gui_menubar = !isNativeMenuBar();
421 #else
422 const bool as_gui_menubar = true;
423 @@ -1791,10 +1853,16 @@ int QMenuBar::heightForWidth(int) const
424 height += 2*vmargin;
426 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
427 +#ifdef Q_WS_X11
428 + if(d->platformMenuBar->allowCornerWidgets()) {
429 +#endif
430 if(d->leftWidget)
431 height = qMax(d->leftWidget->sizeHint().height() + margin, height);
432 if(d->rightWidget)
433 height = qMax(d->rightWidget->sizeHint().height() + margin, height);
434 +#ifdef Q_WS_X11
436 +#endif
437 if(as_gui_menubar) {
438 QStyleOptionMenuItem opt;
439 opt.init(this);
440 @@ -1814,7 +1882,15 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id)
442 Q_Q(QMenuBar);
443 QAction *act = actions.at(id);
444 - setCurrentAction(act, true, true);
445 +#ifdef Q_WS_X11
446 + if (q->isNativeMenuBar()) {
447 + platformMenuBar->popupAction(act);
448 + } else {
449 +#endif
450 + setCurrentAction(act, true, true);
451 +#ifdef Q_WS_X11
453 +#endif
454 if (act && !act->menu()) {
455 activateAction(act, QAction::Trigger);
456 //100 is the same as the default value in QPushButton::animateClick
457 @@ -1835,6 +1911,39 @@ void QMenuBarPrivate::_q_updateLayout()
461 +#ifdef Q_WS_X11
462 +void QMenuBarPrivate::updateCornerWidgetToolBar()
464 + Q_Q(QMenuBar);
465 + if (!cornerWidgetToolBar) {
466 + QMainWindow *window = qobject_cast<QMainWindow *>(q->window());
467 + if (!window) {
468 + qWarning() << "Menubar parent is not a QMainWindow, not showing corner widgets";
469 + return;
471 + cornerWidgetToolBar = window->addToolBar(QApplication::translate("QMenuBar", "Corner Toolbar"));
472 + cornerWidgetToolBar->setObjectName(QLatin1String("CornerToolBar"));
473 + cornerWidgetContainer = new QWidget;
474 + cornerWidgetToolBar->addWidget(cornerWidgetContainer);
475 + new QHBoxLayout(cornerWidgetContainer);
476 + } else {
477 + QLayout *layout = cornerWidgetContainer->layout();
478 + while (layout->count() > 0) {
479 + layout->takeAt(0);
482 + if (leftWidget) {
483 + leftWidget->setParent(cornerWidgetContainer);
484 + cornerWidgetContainer->layout()->addWidget(leftWidget);
486 + if (rightWidget) {
487 + rightWidget->setParent(cornerWidgetContainer);
488 + cornerWidgetContainer->layout()->addWidget(rightWidget);
491 +#endif
495 \fn void QMenuBar::setCornerWidget(QWidget *widget, Qt::Corner corner)
497 @@ -1867,10 +1976,18 @@ void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner)
498 return;
501 +#ifdef Q_WS_X11
502 + if(!d->platformMenuBar->allowCornerWidgets()) {
503 + d->updateCornerWidgetToolBar();
504 + } else {
505 +#endif
506 if (w) {
507 w->setParent(this);
508 w->installEventFilter(this);
510 +#ifdef Q_WS_X11
512 +#endif
514 d->_q_updateLayout();
516 @@ -1920,6 +2037,9 @@ QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const
517 void QMenuBar::setNativeMenuBar(bool nativeMenuBar)
519 Q_D(QMenuBar);
520 +#ifdef Q_WS_X11
521 + d->platformMenuBar->setNativeMenuBar(nativeMenuBar);
522 +#else
523 if (d->nativeMenuBar == -1 || (nativeMenuBar != bool(d->nativeMenuBar))) {
524 d->nativeMenuBar = nativeMenuBar;
525 #ifdef Q_WS_MAC
526 @@ -1944,15 +2064,20 @@ void QMenuBar::setNativeMenuBar(bool nativeMenuBar)
527 setVisible(true);
528 #endif
530 +#endif // Q_WS_X11
533 bool QMenuBar::isNativeMenuBar() const
535 Q_D(const QMenuBar);
536 +#ifdef Q_WS_X11
537 + return d->platformMenuBar->isNativeMenuBar();
538 +#else
539 if (d->nativeMenuBar == -1) {
540 return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar);
542 return d->nativeMenuBar;
543 +#endif
547 diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h
548 index 1ac694e..9a1f758 100644
549 --- a/src/gui/widgets/qmenubar_p.h
550 +++ b/src/gui/widgets/qmenubar_p.h
551 @@ -47,7 +47,7 @@
552 // -------------
554 // This file is not part of the Qt API. It exists purely as an
555 -// implementation detail. This header file may change from version to
556 +// platformMenuBarementation detail. This header file may change from version to
557 // version without notice, or even be removed.
559 // We mean it.
560 @@ -61,6 +61,10 @@
561 #include "qguifunctions_wince.h"
562 #endif
564 +#ifdef Q_WS_X11
565 +#include "qabstractplatformmenubar_p.h"
566 +#endif
568 #ifndef QT_NO_MENUBAR
569 #ifdef Q_WS_S60
570 class CCoeControl;
571 @@ -71,21 +75,27 @@ class CEikMenuBar;
572 QT_BEGIN_NAMESPACE
574 #ifndef QT_NO_MENUBAR
575 +class QToolBar;
576 class QMenuBarExtension;
577 class QMenuBarPrivate : public QWidgetPrivate
579 Q_DECLARE_PUBLIC(QMenuBar)
580 public:
581 QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0),
582 - closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0),
583 - nativeMenuBar(-1), doChildEffects(false)
584 + closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0)
585 +#ifndef Q_WS_X11
586 + , nativeMenuBar(-1)
587 +#endif
588 + , doChildEffects(false)
589 #ifdef QT3_SUPPORT
590 , doAutoResize(false)
591 #endif
592 #ifdef Q_WS_MAC
593 , mac_menubar(0)
594 #endif
596 +#ifdef Q_WS_X11
597 + , platformMenuBar(0)
598 +#endif
599 #ifdef Q_WS_WINCE
600 , wce_menubar(0), wceClassicMenu(false)
601 #endif
602 @@ -96,6 +106,9 @@ public:
604 ~QMenuBarPrivate()
606 +#ifdef Q_WS_X11
607 + delete platformMenuBar;
608 +#endif
609 #ifdef Q_WS_MAC
610 delete mac_menubar;
611 #endif
612 @@ -136,8 +149,9 @@ public:
613 uint keyboardState : 1, altPressed : 1;
614 QPointer<QWidget> keyboardFocusWidget;
617 +#ifndef Q_WS_X11
618 int nativeMenuBar : 3; // Only has values -1, 0, and 1
619 +#endif
620 //firing of events
621 void activateAction(QAction *, QAction::ActionEvent);
623 @@ -173,6 +187,9 @@ public:
624 #ifdef QT3_SUPPORT
625 bool doAutoResize;
626 #endif
627 +#ifdef Q_WS_X11
628 + QAbstractPlatformMenuBar *platformMenuBar;
629 +#endif
630 #ifdef Q_WS_MAC
631 //mac menubar binding
632 struct QMacMenuBarPrivate {
633 @@ -181,7 +198,7 @@ public:
634 QMacMenuBarPrivate();
635 ~QMacMenuBarPrivate();
637 - void addAction(QAction *, QMacMenuAction* =0);
638 + void addAction(QAction *, QAction* =0);
639 void addAction(QMacMenuAction *, QMacMenuAction* =0);
640 void syncAction(QMacMenuAction *);
641 inline void syncAction(QAction *a) { syncAction(findAction(a)); }
642 @@ -220,7 +237,7 @@ public:
644 QWceMenuBarPrivate(QMenuBarPrivate *menubar);
645 ~QWceMenuBarPrivate();
646 - void addAction(QAction *, QWceMenuAction* =0);
647 + void addAction(QAction *, QAction* =0);
648 void addAction(QWceMenuAction *, QWceMenuAction* =0);
649 void syncAction(QWceMenuAction *);
650 inline void syncAction(QAction *a) { syncAction(findAction(a)); }
651 @@ -250,7 +267,7 @@ public:
652 QMenuBarPrivate *d;
653 QSymbianMenuBarPrivate(QMenuBarPrivate *menubar);
654 ~QSymbianMenuBarPrivate();
655 - void addAction(QAction *, QSymbianMenuAction* =0);
656 + void addAction(QAction *, QAction* =0);
657 void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0);
658 void syncAction(QSymbianMenuAction *);
659 inline void syncAction(QAction *a) { syncAction(findAction(a)); }
660 @@ -273,6 +290,12 @@ public:
661 #ifdef QT_SOFTKEYS_ENABLED
662 QAction *menuBarAction;
663 #endif
665 +#ifdef Q_WS_X11
666 + void updateCornerWidgetToolBar();
667 + QToolBar *cornerWidgetToolBar;
668 + QWidget *cornerWidgetContainer;
669 +#endif
671 #endif
673 diff --git a/src/gui/widgets/qmenubar_x11.cpp b/src/gui/widgets/qmenubar_x11.cpp
674 new file mode 100644
675 index 0000000..37c085f
676 --- /dev/null
677 +++ b/src/gui/widgets/qmenubar_x11.cpp
678 @@ -0,0 +1,138 @@
679 +/****************************************************************************
681 +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
682 +** All rights reserved.
683 +** Contact: Nokia Corporation (qt-info@nokia.com)
685 +** This file is part of the QtGui module of the Qt Toolkit.
687 +** $QT_BEGIN_LICENSE:LGPL$
688 +** No Commercial Usage
689 +** This file contains pre-release code and may not be distributed.
690 +** You may use this file in accordance with the terms and conditions
691 +** contained in the Technology Preview License Agreement accompanying
692 +** this package.
694 +** GNU Lesser General Public License Usage
695 +** Alternatively, this file may be used under the terms of the GNU Lesser
696 +** General Public License version 2.1 as published by the Free Software
697 +** Foundation and appearing in the file LICENSE.LGPL included in the
698 +** packaging of this file. Please review the following information to
699 +** ensure the GNU Lesser General Public License version 2.1 requirements
700 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
702 +** In addition, as a special exception, Nokia gives you certain additional
703 +** rights. These rights are described in the Nokia Qt LGPL Exception
704 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
706 +** If you have questions regarding the use of this file, please contact
707 +** Nokia at qt-info@nokia.com.
716 +** $QT_END_LICENSE$
718 +****************************************************************************/
719 +#include "qmenubar_x11_p.h"
721 +#ifndef QT_NO_MENUBAR
723 +#include "qapplication.h"
724 +#include "qdebug.h"
725 +#include "qevent.h"
726 +#include "qmenu.h"
727 +#include "qmenubar.h"
729 +#include <private/qfactoryloader_p.h>
731 +QT_BEGIN_NAMESPACE
733 +QX11MenuBar::~QX11MenuBar()
737 +void QX11MenuBar::init(QMenuBar *_menuBar)
739 + nativeMenuBar = -1;
740 + menuBar = _menuBar;
743 +void QX11MenuBar::setVisible(bool visible)
745 + menuBar->QWidget::setVisible(visible);
748 +void QX11MenuBar::actionEvent(QActionEvent *e)
750 + Q_UNUSED(e);
753 +void QX11MenuBar::handleReparent(QWidget *oldParent, QWidget *newParent, QWidget *oldWindow, QWidget *newWindow)
755 + Q_UNUSED(oldParent)
756 + Q_UNUSED(newParent)
757 + Q_UNUSED(oldWindow)
758 + Q_UNUSED(newWindow)
761 +bool QX11MenuBar::allowCornerWidgets() const
763 + return true;
766 +void QX11MenuBar::popupAction(QAction *)
770 +void QX11MenuBar::setNativeMenuBar(bool value)
772 + if (nativeMenuBar == -1 || (value != bool(nativeMenuBar))) {
773 + nativeMenuBar = value;
777 +bool QX11MenuBar::isNativeMenuBar() const
779 + return false;
782 +bool QX11MenuBar::shortcutsHandledByNativeMenuBar() const
784 + return false;
787 +bool QX11MenuBar::menuBarEventFilter(QObject *, QEvent *)
789 + return false;
792 +struct QX11MenuBarFactory : public QPlatformMenuBarFactoryInterface
794 + QAbstractPlatformMenuBar *create() { return new QX11MenuBar; }
795 + virtual QStringList keys() const { return QStringList(); }
798 +QPlatformMenuBarFactoryInterface *qt_guiPlatformMenuBarFactory()
800 + static QPlatformMenuBarFactoryInterface *factory = 0;
801 + if (!factory) {
802 +#ifndef QT_NO_LIBRARY
803 + QFactoryLoader loader(QPlatformMenuBarFactoryInterface_iid, QLatin1String("/menubar"));
804 + factory = qobject_cast<QPlatformMenuBarFactoryInterface *>(loader.instance(QLatin1String("default")));
805 +#endif // QT_NO_LIBRARY
806 + if(!factory) {
807 + static QX11MenuBarFactory def;
808 + factory = &def;
811 + return factory;
814 +QT_END_NAMESPACE
816 +#endif // QT_NO_MENUBAR
817 diff --git a/src/gui/widgets/qmenubar_x11_p.h b/src/gui/widgets/qmenubar_x11_p.h
818 new file mode 100644
819 index 0000000..1c43b04
820 --- /dev/null
821 +++ b/src/gui/widgets/qmenubar_x11_p.h
822 @@ -0,0 +1,86 @@
823 +/****************************************************************************
825 +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
826 +** All rights reserved.
827 +** Contact: Nokia Corporation (qt-info@nokia.com)
829 +** This file is part of the QtGui module of the Qt Toolkit.
831 +** $QT_BEGIN_LICENSE:LGPL$
832 +** No Commercial Usage
833 +** This file contains pre-release code and may not be distributed.
834 +** You may use this file in accordance with the terms and conditions
835 +** contained in the Technology Preview License Agreement accompanying
836 +** this package.
838 +** GNU Lesser General Public License Usage
839 +** Alternatively, this file may be used under the terms of the GNU Lesser
840 +** General Public License version 2.1 as published by the Free Software
841 +** Foundation and appearing in the file LICENSE.LGPL included in the
842 +** packaging of this file. Please review the following information to
843 +** ensure the GNU Lesser General Public License version 2.1 requirements
844 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
846 +** In addition, as a special exception, Nokia gives you certain additional
847 +** rights. These rights are described in the Nokia Qt LGPL Exception
848 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
850 +** If you have questions regarding the use of this file, please contact
851 +** Nokia at qt-info@nokia.com.
860 +** $QT_END_LICENSE$
862 +****************************************************************************/
863 +#ifndef QX11MENUBAR_P_H
864 +#define QX11MENUBAR_P_H
866 +#ifndef QT_NO_MENUBAR
868 +#include "qabstractplatformmenubar_p.h"
870 +QT_BEGIN_NAMESPACE
872 +class QMenuBar;
874 +class QX11MenuBar : public QAbstractPlatformMenuBar
876 +public:
877 + ~QX11MenuBar();
879 + virtual void init(QMenuBar *);
881 + virtual void setVisible(bool visible);
883 + virtual void actionEvent(QActionEvent *e);
885 + virtual void handleReparent(QWidget *oldParent, QWidget *newParent, QWidget *oldWindow, QWidget *newWindow);
887 + virtual bool allowCornerWidgets() const;
889 + virtual void popupAction(QAction*);
891 + virtual void setNativeMenuBar(bool);
892 + virtual bool isNativeMenuBar() const;
894 + virtual bool shortcutsHandledByNativeMenuBar() const;
895 + virtual bool menuBarEventFilter(QObject *, QEvent *event);
897 +private:
898 + QMenuBar *menuBar;
899 + int nativeMenuBar : 3; // Only has values -1, 0, and 1
902 +QPlatformMenuBarFactoryInterface *qt_guiPlatformMenuBarFactory();
904 +QT_END_NAMESPACE
906 +#endif // QT_NO_MENUBAR
908 +#endif /* QX11MENUBAR_P_H */
909 diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri
910 index 937b8d6..bd8a735 100644
911 --- a/src/gui/widgets/widgets.pri
912 +++ b/src/gui/widgets/widgets.pri
913 @@ -144,6 +144,14 @@ SOURCES += \
914 widgets/qplaintextedit.cpp \
915 widgets/qprintpreviewwidget.cpp
917 +x11: {
918 + HEADERS += \
919 + widgets/qabstractplatformmenubar_p.h
921 + SOURCES += \
922 + widgets/qmenubar_x11.cpp
925 !embedded:mac {
926 HEADERS += widgets/qmacnativewidget_mac.h \
927 widgets/qmaccocoaviewcontainer_mac.h