summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qabstractbutton.cpp43
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp13
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h2
-rw-r--r--src/gui/widgets/qabstractspinbox.cpp5
-rw-r--r--src/gui/widgets/qbuttongroup.cpp17
-rw-r--r--src/gui/widgets/qcalendarwidget.cpp14
-rw-r--r--src/gui/widgets/qcombobox.cpp37
-rw-r--r--src/gui/widgets/qcombobox_p.h3
-rw-r--r--src/gui/widgets/qcommandlinkbutton.cpp9
-rw-r--r--src/gui/widgets/qdatetimeedit.cpp8
-rw-r--r--src/gui/widgets/qdockarealayout.cpp8
-rw-r--r--src/gui/widgets/qdockwidget.cpp86
-rw-r--r--src/gui/widgets/qeffects.cpp8
-rw-r--r--src/gui/widgets/qframe.cpp4
-rw-r--r--src/gui/widgets/qframe_p.h3
-rw-r--r--src/gui/widgets/qgroupbox.cpp12
-rw-r--r--src/gui/widgets/qlabel.cpp24
-rw-r--r--src/gui/widgets/qlcdnumber.cpp12
-rw-r--r--src/gui/widgets/qlineedit.cpp6
-rw-r--r--src/gui/widgets/qmainwindowlayout_mac.mm4
-rw-r--r--src/gui/widgets/qmainwindowlayout_p.h30
-rw-r--r--src/gui/widgets/qmdiarea.cpp34
-rw-r--r--src/gui/widgets/qmdisubwindow.cpp38
-rw-r--r--src/gui/widgets/qmdisubwindow_p.h4
-rw-r--r--src/gui/widgets/qmenu.cpp70
-rw-r--r--src/gui/widgets/qmenu.h4
-rw-r--r--src/gui/widgets/qmenu_mac.mm184
-rw-r--r--src/gui/widgets/qmenu_p.h12
-rw-r--r--src/gui/widgets/qmenu_wince.cpp4
-rw-r--r--src/gui/widgets/qmenubar.cpp157
-rw-r--r--src/gui/widgets/qmenubar.h8
-rw-r--r--src/gui/widgets/qmenubar_p.h15
-rw-r--r--src/gui/widgets/qplaintextedit.cpp25
-rw-r--r--src/gui/widgets/qprintpreviewwidget.cpp44
-rw-r--r--src/gui/widgets/qprogressbar.cpp8
-rw-r--r--src/gui/widgets/qpushbutton.cpp9
-rw-r--r--src/gui/widgets/qsizegrip.cpp2
-rw-r--r--src/gui/widgets/qslider.cpp10
-rw-r--r--src/gui/widgets/qspinbox.cpp23
-rw-r--r--src/gui/widgets/qsplitter.cpp14
-rw-r--r--src/gui/widgets/qsplitter_p.h9
-rw-r--r--src/gui/widgets/qstatusbar.cpp4
-rw-r--r--src/gui/widgets/qtabbar.cpp7
-rw-r--r--src/gui/widgets/qtabwidget.cpp2
-rw-r--r--src/gui/widgets/qtextbrowser.cpp8
-rw-r--r--src/gui/widgets/qtoolbar.cpp26
-rw-r--r--src/gui/widgets/qtoolbararealayout.cpp91
-rw-r--r--src/gui/widgets/qtoolbararealayout_p.h57
-rw-r--r--src/gui/widgets/qtoolbarlayout.cpp21
-rw-r--r--src/gui/widgets/qtoolbarlayout_p.h6
-rw-r--r--src/gui/widgets/qtoolbutton.cpp13
-rw-r--r--src/gui/widgets/qvalidator.cpp2
-rw-r--r--src/gui/widgets/qwidgetresizehandler.cpp2
53 files changed, 691 insertions, 570 deletions
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp
index 61ed0ea..6337b5c 100644
--- a/src/gui/widgets/qabstractbutton.cpp
+++ b/src/gui/widgets/qabstractbutton.cpp
@@ -215,11 +215,8 @@ void QButtonGroup::setExclusive(bool exclusive)
d->exclusive = exclusive;
}
-/*!
- Adds the given \a button to the end of the group's internal list of buttons.
- \sa removeButton()
-*/
+// TODO: Qt 5: Merge with addButton(QAbstractButton *button, int id)
void QButtonGroup::addButton(QAbstractButton *button)
{
addButton(button, -1);
@@ -232,8 +229,18 @@ void QButtonGroup::addButton(QAbstractButton *button, int id)
previous->removeButton(button);
button->d_func()->group = this;
d->buttonList.append(button);
- if (id != -1)
+ if (id == -1) {
+ QList<int> ids = d->mapping.values();
+ if (ids.isEmpty())
+ d->mapping[button] = -2;
+ else {
+ qSort(ids);
+ d->mapping[button] = ids.first()-1;
+ }
+ } else {
d->mapping[button] = id;
+ }
+
if (d->exclusive && button->isChecked())
button->d_func()->notifyChecked();
}
@@ -312,20 +319,16 @@ QList<QAbstractButton *>QAbstractButtonPrivate::queryButtonList() const
return group->d_func()->buttonList;
#endif
- Q_Q(const QAbstractButton);
- QList<QAbstractButton*>candidates;
- if (q->parentWidget()) {
- candidates = qFindChildren<QAbstractButton *>(q->parentWidget());
- if (autoExclusive) {
- for (int i = candidates.count() - 1; i >= 0; --i) {
- QAbstractButton *candidate = candidates.at(i);
- if (!candidate->autoExclusive()
+ QList<QAbstractButton*>candidates = qFindChildren<QAbstractButton *>(parent);
+ if (autoExclusive) {
+ for (int i = candidates.count() - 1; i >= 0; --i) {
+ QAbstractButton *candidate = candidates.at(i);
+ if (!candidate->autoExclusive()
#ifndef QT_NO_BUTTONGROUP
- || candidate->group()
+ || candidate->group()
#endif
- )
- candidates.removeAt(i);
- }
+ )
+ candidates.removeAt(i);
}
}
return candidates;
@@ -376,7 +379,7 @@ void QAbstractButtonPrivate::moveFocus(int key)
#else
bool exclusive = autoExclusive;
#endif
- QWidget *f = qApp->focusWidget();
+ QWidget *f = QApplication::focusWidget();
QAbstractButton *fb = qobject_cast<QAbstractButton *>(f);
if (!fb || !buttonList.contains(fb))
return;
@@ -1236,7 +1239,9 @@ void QAbstractButton::timerEvent(QTimerEvent *e)
d->repeatTimer.start(d->autoRepeatInterval, this);
if (d->down) {
QPointer<QAbstractButton> guard(this);
- d->emitReleased();
+ nextCheckState();
+ if (guard)
+ d->emitReleased();
if (guard)
d->emitClicked();
if (guard)
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 1ff56e8..de43616 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -884,21 +884,22 @@ bool QAbstractScrollArea::event(QEvent *e)
case QEvent::Resize:
d->layoutChildren();
break;
- case QEvent::Paint:
+ case QEvent::Paint: {
+ QStyleOption option;
+ option.initFrom(this);
if (d->cornerPaintingRect.isValid()) {
- QStyleOption option;
option.rect = d->cornerPaintingRect;
QPainter p(this);
style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this);
}
#ifdef Q_WS_MAC
if (d->reverseCornerPaintingRect.isValid()) {
- QStyleOption option;
option.rect = d->reverseCornerPaintingRect;
QPainter p(this);
style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this);
}
#endif
+ }
QFrame::paintEvent((QPaintEvent*)e);
break;
#ifndef QT_NO_CONTEXTMENU
@@ -1275,6 +1276,12 @@ QSize QAbstractScrollArea::minimumSizeHint() const
int hsbExt = d->hbar->sizeHint().height();
int vsbExt = d->vbar->sizeHint().width();
int extra = 2 * d->frameWidth;
+ QStyleOption opt;
+ opt.initFrom(this);
+ if ((d->frameStyle != QFrame::NoFrame)
+ && style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, this)) {
+ extra += style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, this);
+ }
return QSize(d->scrollBarContainers[Qt::Horizontal]->sizeHint().width() + vsbExt + extra,
d->scrollBarContainers[Qt::Vertical]->sizeHint().height() + hsbExt + extra);
}
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index 999bdfc..ebdd281 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QScrollBar;
class QAbstractScrollAreaScrollBarContainer;
-class Q_GUI_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
+class QAbstractScrollAreaPrivate: public QFramePrivate
{
Q_DECLARE_PUBLIC(QAbstractScrollArea)
diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp
index 2bf1cda..d52af19 100644
--- a/src/gui/widgets/qabstractspinbox.cpp
+++ b/src/gui/widgets/qabstractspinbox.cpp
@@ -193,6 +193,7 @@ void QAbstractSpinBox::setButtonSymbols(ButtonSymbols buttonSymbols)
Q_D(QAbstractSpinBox);
if (d->buttonSymbols != buttonSymbols) {
d->buttonSymbols = buttonSymbols;
+ d->updateEditFieldGeometry();
update();
}
}
@@ -1791,8 +1792,8 @@ void QAbstractSpinBoxPrivate::interpret(EmitPolicy ep)
q->fixup(tmp);
QASBDEBUG() << "QAbstractSpinBoxPrivate::interpret() text '"
<< edit->displayText()
- << "' >> '" << copy << "'"
- << "' >> '" << tmp << "'";
+ << "' >> '" << copy << '\''
+ << "' >> '" << tmp << '\'';
doInterpret = tmp != copy && (q->validate(tmp, pos) == QValidator::Acceptable);
if (!doInterpret) {
diff --git a/src/gui/widgets/qbuttongroup.cpp b/src/gui/widgets/qbuttongroup.cpp
index 06bcf1e..1003523 100644
--- a/src/gui/widgets/qbuttongroup.cpp
+++ b/src/gui/widgets/qbuttongroup.cpp
@@ -176,11 +176,22 @@
*/
/*!
- \fn void QButtonGroup::addButton(QAbstractButton *button, int id = -1);
+ \fn void QButtonGroup::addButton(QAbstractButton *button);
+
+ Adds the given \a button to the end of the group's internal list
+ of buttons. An id will be assigned to the button by this
+ QButtonGroup. Automatically assigned ids are guaranteed to be
+ negative, starting with -2. If you are also assigning your own
+ ids, use positive values to avoid conflicts.
+
+ \sa removeButton() buttons()
+*/
+
+/*!
+ \fn void QButtonGroup::addButton(QAbstractButton *button, int id);
Adds the given \a button to the button group, with the given \a
- id. If \a id is -1 (the default), an id will be assigned to the
- button by this QButtonGroup.
+ id. It is recommended to assign only positive ids.
\sa removeButton() buttons()
*/
diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp
index 4436c04..8703139 100644
--- a/src/gui/widgets/qcalendarwidget.cpp
+++ b/src/gui/widgets/qcalendarwidget.cpp
@@ -198,7 +198,7 @@ QString QCalendarDayValidator::text() const
{
QString str;
if (m_day / 10 == 0)
- str += QLatin1String("0");
+ str += QLatin1Char('0');
str += QString::number(m_day);
return highlightString(str, m_pos);
}
@@ -210,7 +210,7 @@ QString QCalendarDayValidator::text(const QDate &date, int repeat) const
} else if (repeat == 2) {
QString str;
if (date.day() / 10 == 0)
- str += QLatin1String("0");
+ str += QLatin1Char('0');
return str + QString::number(date.day());
} else if (repeat == 3) {
return m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat);
@@ -316,7 +316,7 @@ QString QCalendarMonthValidator::text() const
{
QString str;
if (m_month / 10 == 0)
- str += QLatin1String("0");
+ str += QLatin1Char('0');
str += QString::number(m_month);
return highlightString(str, m_pos);
}
@@ -328,7 +328,7 @@ QString QCalendarMonthValidator::text(const QDate &date, int repeat) const
} else if (repeat == 2) {
QString str;
if (date.month() / 10 == 0)
- str += QLatin1String("0");
+ str += QLatin1Char('0');
return str + QString::number(date.month());
} else if (repeat == 3) {
return m_locale.standaloneMonthName(date.month(), QLocale::ShortFormat);
@@ -432,7 +432,7 @@ QString QCalendarYearValidator::text() const
int pow = 10;
for (int i = 0; i < 3; i++) {
if (m_year / pow == 0)
- str += QLatin1String("0");
+ str += QLatin1Char('0');
pow *= 10;
}
str += QString::number(m_year);
@@ -445,7 +445,7 @@ QString QCalendarYearValidator::text(const QDate &date, int repeat) const
QString str;
int year = date.year() % 100;
if (year / 10 == 0)
- str = QLatin1String("0");
+ str = QLatin1Char('0');
return str + QString::number(year);
}
return QString::number(date.year());
@@ -577,7 +577,7 @@ void QCalendarDateValidator::setFormat(const QString &format)
clear();
int pos = 0;
- const QLatin1String quote("'");
+ const QLatin1Char quote('\'');
bool quoting = false;
QString separator;
while (pos < format.size()) {
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index a6a5e08..bd01da0 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -953,6 +953,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer()
container->itemView()->setTextElideMode(Qt::ElideMiddle);
updateDelegate(true);
updateLayoutDirection();
+ updateViewContainerPaletteAndOpacity();
QObject::connect(container, SIGNAL(itemSelected(QModelIndex)),
q, SLOT(_q_itemSelected(QModelIndex)));
QObject::connect(container->itemView()->selectionModel(),
@@ -1055,6 +1056,27 @@ void QComboBoxPrivate::_q_rowsRemoved(const QModelIndex &parent, int /*start*/,
}
+void QComboBoxPrivate::updateViewContainerPaletteAndOpacity()
+{
+ if (!container)
+ return;
+ Q_Q(QComboBox);
+ QStyleOptionComboBox opt;
+ q->initStyleOption(&opt);
+#ifndef QT_NO_MENU
+ if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) {
+ QMenu menu;
+ menu.ensurePolished();
+ container->setPalette(menu.palette());
+ container->setWindowOpacity(menu.windowOpacity());
+ } else
+#endif
+ {
+ container->setPalette(q->palette());
+ container->setWindowOpacity(1.0);
+ }
+}
+
/*!
Initialize \a option with the values from this QComboBox. This method
is useful for subclasses when they need a QStyleOptionComboBox, but don't want
@@ -2591,20 +2613,7 @@ void QComboBox::changeEvent(QEvent *e)
hidePopup();
break;
case QEvent::PaletteChange: {
- QStyleOptionComboBox opt;
- initStyleOption(&opt);
-#ifndef QT_NO_MENU
- if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
- QMenu menu;
- menu.ensurePolished();
- d->viewContainer()->setPalette(menu.palette());
- d->viewContainer()->setWindowOpacity(menu.windowOpacity());
- } else
-#endif
- {
- d->viewContainer()->setPalette(palette());
- d->viewContainer()->setWindowOpacity(1.0);
- }
+ d->updateViewContainerPaletteAndOpacity();
break;
}
case QEvent::FontChange:
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index a55b439..0998e52 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -290,7 +290,7 @@ public:
QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {}
static bool isSeparator(const QModelIndex &index) {
- return index.data(Qt::AccessibleDescriptionRole).toString() == QString::fromLatin1("separator");
+ return index.data(Qt::AccessibleDescriptionRole).toString() == QLatin1String("separator");
}
static void setSeparator(QAbstractItemModel *model, const QModelIndex &index) {
model->setData(index, QString::fromLatin1("separator"), Qt::AccessibleDescriptionRole);
@@ -370,6 +370,7 @@ public:
void updateDelegate(bool force = false);
void keyboardSearchString(const QString &text);
void modelChanged();
+ void updateViewContainerPaletteAndOpacity();
QAbstractItemModel *model;
QLineEdit *lineEdit;
diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp
index 13ee6af..92d89a1 100644
--- a/src/gui/widgets/qcommandlinkbutton.cpp
+++ b/src/gui/widgets/qcommandlinkbutton.cpp
@@ -140,10 +140,12 @@ QFont QCommandLinkButtonPrivate::titleFont() const
Q_Q(const QCommandLinkButton);
QFont font = q->font();
if (usingVistaStyle()) {
- font.setPointSizeF(12.0);
+ if (!q->testAttribute(Qt::WA_SetFont))
+ font.setPointSizeF(12.0);
} else {
font.setBold(true);
- font.setPointSizeF(9.0);
+ if (!q->testAttribute(Qt::WA_SetFont))
+ font.setPointSizeF(9.0);
}
return font;
}
@@ -152,7 +154,8 @@ QFont QCommandLinkButtonPrivate::descriptionFont() const
{
Q_Q(const QCommandLinkButton);
QFont font = q->font();
- font.setPointSizeF(9.0);
+ if (!q->testAttribute(Qt::WA_SetFont))
+ font.setPointSizeF(9.0);
return font;
}
diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index 4d34691..4d47a50 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -220,6 +220,9 @@ QDateTimeEdit::QDateTimeEdit(const QVariant &var, QVariant::Type parserType, QWi
\property QDateTimeEdit::dateTime
\brief the QDateTime that is set in the QDateTimeEdit
+ When setting this property the timespec of the QDateTimeEdit remains the same
+ and the timespec of the new QDateTime is ignored.
+
By default, this property contains a date that refers to January 1,
2000 and a time of 00:00:00 and 0 milliseconds.
@@ -239,7 +242,7 @@ void QDateTimeEdit::setDateTime(const QDateTime &datetime)
d->clearCache();
if (!(d->sections & DateSections_Mask))
setDateRange(datetime.date(), datetime.date());
- d->setValue(QVariant(datetime), EmitIfChanged);
+ d->setValue(QDateTime(datetime.date(), datetime.time(), d->spec), EmitIfChanged);
}
}
@@ -932,9 +935,6 @@ void QDateTimeEdit::setCalendarPopup(bool enable)
\property QDateTimeEdit::timeSpec
\brief the current timespec used by the date time edit.
\since 4.4
-
- All dates/passed to the date time edit will be converted to this
- timespec.
*/
Qt::TimeSpec QDateTimeEdit::timeSpec() const
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index 4f0ec1e..58e8f9c 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -2202,8 +2202,8 @@ QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const
{
QSet<QWidget*> result;
- foreach (QWidget *sepWidget, separatorWidgets)
- result << sepWidget;
+ for (int i = 0; i < separatorWidgets.count(); ++i)
+ result << separatorWidgets.at(i);
for (int i = 0; i < item_list.count(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
@@ -3244,8 +3244,8 @@ QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const
{
QSet<QWidget*> result;
- foreach (QWidget *sepWidget, separatorWidgets)
- result << sepWidget;
+ for (int i = 0; i < separatorWidgets.count(); ++i)
+ result << separatorWidgets.at(i);
for (int i = 0; i < QInternal::DockCount; ++i) {
const QDockAreaLayoutInfo &dock = docks[i];
result += dock.usedSeparatorWidgets();
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index a5be5f8..e20fedd 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -69,6 +69,9 @@ extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); /
extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp
+static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
+{ return (priv->features & feature) == feature; }
+
static inline bool hasFeature(const QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature)
{ return (dockwidget->features() & feature) == feature; }
@@ -203,7 +206,7 @@ bool QDockWidgetLayout::nativeWindowDeco() const
bool QDockWidgetLayout::nativeWindowDeco(bool floating) const
{
-#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_WINCE)
+#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_WINCE)
Q_UNUSED(floating);
return false;
#else
@@ -221,7 +224,8 @@ void QDockWidgetLayout::addItem(QLayoutItem*)
QLayoutItem *QDockWidgetLayout::itemAt(int index) const
{
int cnt = 0;
- foreach (QLayoutItem *item, item_list) {
+ for (int i = 0; i < item_list.count(); ++i) {
+ QLayoutItem *item = item_list.at(i);
if (item == 0)
continue;
if (index == cnt++)
@@ -250,8 +254,8 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index)
int QDockWidgetLayout::count() const
{
int result = 0;
- foreach (QLayoutItem *item, item_list) {
- if (item != 0)
+ for (int i = 0; i < item_list.count(); ++i) {
+ if (item_list.at(i))
++result;
}
return result;
@@ -646,25 +650,25 @@ void QDockWidgetPrivate::_q_toggleView(bool b)
void QDockWidgetPrivate::updateButtons()
{
Q_Q(QDockWidget);
- QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout());
+ QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
QStyleOptionDockWidget opt;
q->initStyleOption(&opt);
- bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
- bool nativeDeco = layout->nativeWindowDeco();
+ bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
+ bool nativeDeco = dwLayout->nativeWindowDeco();
bool hideButtons = nativeDeco || customTitleBar;
- bool canClose = hasFeature(q, QDockWidget::DockWidgetClosable);
- bool canFloat = hasFeature(q, QDockWidget::DockWidgetFloatable);
+ bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable);
+ bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable);
QAbstractButton *button
- = qobject_cast<QAbstractButton*>(layout->widgetForRole(QDockWidgetLayout::FloatButton));
+ = qobject_cast<QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::FloatButton));
button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q));
button->setVisible(canFloat && !hideButtons);
button
- = qobject_cast <QAbstractButton*>(layout->widgetForRole(QDockWidgetLayout::CloseButton));
+ = qobject_cast <QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::CloseButton));
button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q));
button->setVisible(canClose && !hideButtons);
@@ -687,7 +691,7 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
if (state != 0)
return;
- QMainWindow *win = qobject_cast<QMainWindow*>(q->parentWidget());
+ QMainWindow *win = qobject_cast<QMainWindow*>(parent);
Q_ASSERT(win != 0);
QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
Q_ASSERT(layout != 0);
@@ -740,15 +744,15 @@ void QDockWidgetPrivate::endDrag(bool abort)
q->releaseMouse();
if (state->dragging) {
- QMainWindowLayout *layout =
+ QMainWindowLayout *mwLayout =
qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
- Q_ASSERT(layout != 0);
+ Q_ASSERT(mwLayout != 0);
- if (abort || !layout->plug(state->widgetItem)) {
- if (hasFeature(q, QDockWidget::DockWidgetFloatable)) {
+ if (abort || !mwLayout->plug(state->widgetItem)) {
+ if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
if (state->ownWidgetItem)
delete state->widgetItem;
- layout->restore();
+ mwLayout->restore();
#ifdef Q_WS_X11
// get rid of the X11BypassWindowManager window flag and activate the resizer
Qt::WindowFlags flags = q->windowFlags();
@@ -758,14 +762,14 @@ void QDockWidgetPrivate::endDrag(bool abort)
q->show();
#else
QDockWidgetLayout *myLayout
- = qobject_cast<QDockWidgetLayout*>(q->layout());
+ = qobject_cast<QDockWidgetLayout*>(layout);
resizer->setActive(QWidgetResizeHandler::Resize,
myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0);
#endif
undockedGeometry = q->geometry();
q->activateWindow();
} else {
- layout->revert(state->widgetItem);
+ mwLayout->revert(state->widgetItem);
}
}
}
@@ -777,7 +781,7 @@ bool QDockWidgetPrivate::isAnimating() const
{
Q_Q(const QDockWidget);
- QMainWindow *mainWin = qobject_cast<QMainWindow*>(q->parentWidget());
+ QMainWindow *mainWin = qobject_cast<QMainWindow*>(parent);
if (mainWin == 0)
return false;
@@ -794,18 +798,18 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
#if !defined(QT_NO_MAINWINDOW)
Q_Q(QDockWidget);
- QDockWidgetLayout *layout
- = qobject_cast<QDockWidgetLayout*>(q->layout());
+ QDockWidgetLayout *dwLayout
+ = qobject_cast<QDockWidgetLayout*>(layout);
- if (!layout->nativeWindowDeco()) {
- QRect titleArea = layout->titleArea();
+ if (!dwLayout->nativeWindowDeco()) {
+ QRect titleArea = dwLayout->titleArea();
if (event->button() != Qt::LeftButton ||
!titleArea.contains(event->pos()) ||
// check if the tool window is movable... do nothing if it
// is not (but allow moving if the window is floating)
- (!hasFeature(q, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
- qobject_cast<QMainWindow*>(q->parentWidget()) == 0 ||
+ (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
+ qobject_cast<QMainWindow*>(parent) == 0 ||
isAnimating() || state != 0) {
return false;
}
@@ -813,7 +817,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
initDrag(event->pos(), false);
if (state)
- state->ctrlDrag = hasFeature(q, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;
+ state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;
return true;
}
@@ -824,15 +828,13 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event)
{
- Q_Q(QDockWidget);
+ QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
- QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout());
-
- if (!layout->nativeWindowDeco()) {
- QRect titleArea = layout->titleArea();
+ if (!dwLayout->nativeWindowDeco()) {
+ QRect titleArea = dwLayout->titleArea();
if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) &&
- hasFeature(q, QDockWidget::DockWidgetFloatable)) {
+ hasFeature(this, QDockWidget::DockWidgetFloatable)) {
_q_toggleTopLevel();
return true;
}
@@ -850,7 +852,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
return ret;
QDockWidgetLayout *dwlayout
- = qobject_cast<QDockWidgetLayout*>(q->layout());
+ = qobject_cast<QDockWidgetLayout*>(layout);
QMainWindowLayout *mwlayout
= qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout());
if (!dwlayout->nativeWindowDeco()) {
@@ -923,7 +925,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
break;
if (state != 0)
break;
- if (qobject_cast<QMainWindow*>(q->parentWidget()) == 0)
+ if (qobject_cast<QMainWindow*>(parent) == 0)
break;
if (isAnimating())
break;
@@ -996,9 +998,9 @@ void QDockWidgetPrivate::unplug(const QRect &rect)
Q_Q(QDockWidget);
QRect r = rect;
r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
- QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout());
- if (layout->nativeWindowDeco(true))
- r.adjust(0, layout->titleHeight(), 0, 0);
+ QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
+ if (dwLayout->nativeWindowDeco(true))
+ r.adjust(0, dwLayout->titleHeight(), 0, 0);
setWindowState(true, true, r);
}
@@ -1019,12 +1021,12 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;
- QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout());
- const bool nativeDeco = layout->nativeWindowDeco(floating);
+ QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
+ const bool nativeDeco = dwLayout->nativeWindowDeco(floating);
if (nativeDeco) {
flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
- if (hasFeature(q, QDockWidget::DockWidgetClosable))
+ if (hasFeature(this, QDockWidget::DockWidgetClosable))
flags |= Qt::WindowCloseButtonHint;
} else {
flags |= Qt::FramelessWindowHint;
@@ -1051,7 +1053,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
if (floating != wasFloating) {
emit q->topLevelChanged(floating);
- if (!floating && q->parentWidget()) {
+ if (!floating && parent) {
QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
if (mwlayout)
emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
diff --git a/src/gui/widgets/qeffects.cpp b/src/gui/widgets/qeffects.cpp
index 140953d..19cdf89 100644
--- a/src/gui/widgets/qeffects.cpp
+++ b/src/gui/widgets/qeffects.cpp
@@ -588,8 +588,8 @@ void qScrollEffect(QWidget* w, QEffects::DirFlags orient, int time)
if (!w)
return;
- qApp->sendPostedEvents(w, QEvent::Move);
- qApp->sendPostedEvents(w, QEvent::Resize);
+ QApplication::sendPostedEvents(w, QEvent::Move);
+ QApplication::sendPostedEvents(w, QEvent::Resize);
Qt::WindowFlags flags = Qt::ToolTip;
// those can be popups - they would steal the focus, but are disabled
@@ -610,8 +610,8 @@ void qFadeEffect(QWidget* w, int time)
if (!w)
return;
- qApp->sendPostedEvents(w, QEvent::Move);
- qApp->sendPostedEvents(w, QEvent::Resize);
+ QApplication::sendPostedEvents(w, QEvent::Move);
+ QApplication::sendPostedEvents(w, QEvent::Resize);
Qt::WindowFlags flags = Qt::ToolTip;
diff --git a/src/gui/widgets/qframe.cpp b/src/gui/widgets/qframe.cpp
index 6f81331..22a990b 100644
--- a/src/gui/widgets/qframe.cpp
+++ b/src/gui/widgets/qframe.cpp
@@ -59,8 +59,7 @@ QFramePrivate::QFramePrivate()
midLineWidth(0),
frameWidth(0),
leftFrameWidth(0), rightFrameWidth(0),
- topFrameWidth(0), bottomFrameWidth(0),
- oldFrameStyle(QFrame::NoFrame | QFrame::Plain)
+ topFrameWidth(0), bottomFrameWidth(0)
{
}
@@ -333,7 +332,6 @@ void QFrame::setFrameStyle(int style)
d->frameStyle = (short)style;
update();
d->updateFrameWidth();
- d->oldFrameStyle = (short)style;
}
/*!
diff --git a/src/gui/widgets/qframe_p.h b/src/gui/widgets/qframe_p.h
index 4fd341d..537f5bf 100644
--- a/src/gui/widgets/qframe_p.h
+++ b/src/gui/widgets/qframe_p.h
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-class Q_GUI_EXPORT QFramePrivate : public QWidgetPrivate
+class QFramePrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QFrame)
public:
@@ -74,7 +74,6 @@ public:
short frameWidth;
short leftFrameWidth, rightFrameWidth;
short topFrameWidth, bottomFrameWidth;
- short oldFrameStyle;
inline void init();
diff --git a/src/gui/widgets/qgroupbox.cpp b/src/gui/widgets/qgroupbox.cpp
index 6a82483..876c5d6 100644
--- a/src/gui/widgets/qgroupbox.cpp
+++ b/src/gui/widgets/qgroupbox.cpp
@@ -644,15 +644,11 @@ bool QGroupBox::isChecked() const
void QGroupBox::setChecked(bool b)
{
Q_D(QGroupBox);
- if (d->checkable) {
- if (d->checked != b)
- update();
- bool wasToggled = (b != d->checked);
+ if (d->checkable && b != d->checked) {
+ update();
d->checked = b;
- if (wasToggled) {
- d->_q_setChildrenEnabled(b);
- emit toggled(b);
- }
+ d->_q_setChildrenEnabled(b);
+ emit toggled(b);
}
}
diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp
index 63c1315..1aef133 100644
--- a/src/gui/widgets/qlabel.cpp
+++ b/src/gui/widgets/qlabel.cpp
@@ -971,6 +971,13 @@ void QLabel::paintEvent(QPaintEvent *)
#endif
if (d->isTextLabel) {
QRectF lr = d->layoutRect();
+ QStyleOption opt;
+ opt.initFrom(this);
+#ifndef QT_NO_STYLE_STYLESHEET
+ if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style)) {
+ cssStyle->styleSheetPalette(this, &opt, &opt.palette);
+ }
+#endif
if (d->control) {
#ifndef QT_NO_SHORTCUT
const bool underline = (bool)style->styleHint(QStyle::SH_UnderlineShortcut, 0, this, 0);
@@ -984,11 +991,9 @@ void QLabel::paintEvent(QPaintEvent *)
d->ensureTextLayouted();
QAbstractTextDocumentLayout::PaintContext context;
- QStyleOption opt(0);
- opt.init(this);
if (!isEnabled() && style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)) {
- context.palette = palette();
+ context.palette = opt.palette;
context.palette.setColor(QPalette::Text, context.palette.light().color());
painter.save();
painter.translate(lr.x() + 1, lr.y() + 1);
@@ -999,12 +1004,7 @@ void QLabel::paintEvent(QPaintEvent *)
}
// Adjust the palette
- context.palette = palette();
-#ifndef QT_NO_STYLE_STYLESHEET
- if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style)) {
- cssStyle->focusPalette(this, &opt, &context.palette);
- }
-#endif
+ context.palette = opt.palette;
if (foregroundRole() != QPalette::Text && isEnabled())
context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));
@@ -1019,12 +1019,10 @@ void QLabel::paintEvent(QPaintEvent *)
int flags = align;
if (d->hasShortcut) {
flags |= Qt::TextShowMnemonic;
- QStyleOption opt;
- opt.initFrom(this);
if (!style->styleHint(QStyle::SH_UnderlineShortcut, &opt, this))
flags |= Qt::TextHideMnemonic;
}
- style->drawItemText(&painter, lr.toRect(), flags, palette(), isEnabled(), d->text, foregroundRole());
+ style->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), d->text, foregroundRole());
}
} else
#ifndef QT_NO_PICTURE
@@ -1172,7 +1170,7 @@ void QLabelPrivate::updateShortcut()
shortcutCursor.deleteChar(); // remove the ampersand
shortcutCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
} else {
- if (!text.contains(QLatin1String("&")))
+ if (!text.contains(QLatin1Char('&')))
return;
hasShortcut = true;
shortcutId = q->grabShortcut(QKeySequence::mnemonic(text));
diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp
index af80963..6686d7e 100644
--- a/src/gui/widgets/qlcdnumber.cpp
+++ b/src/gui/widgets/qlcdnumber.cpp
@@ -403,7 +403,7 @@ QLCDNumber::QLCDNumber(QWidget *parent)
Constructs an LCD number, sets the number of digits to \a
numDigits, the base to decimal, the decimal point mode to 'small'
and the frame style to a raised box. The segmentStyle() is set to
- \c Outline.
+ \c Filled.
The \a parent argument is passed to the QFrame constructor.
@@ -427,7 +427,7 @@ void QLCDNumberPrivate::init()
base = QLCDNumber::Dec;
smallPoint = false;
q->setNumDigits(ndigits);
- q->setSegmentStyle(QLCDNumber::Outline);
+ q->setSegmentStyle(QLCDNumber::Filled);
q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
}
@@ -756,6 +756,10 @@ void QLCDNumber::paintEvent(QPaintEvent *)
Q_D(QLCDNumber);
QPainter p(this);
drawFrame(&p);
+ p.setRenderHint(QPainter::Antialiasing);
+ if (d->shadow)
+ p.translate(0.5, 0.5);
+
if (d->smallPoint)
d->drawString(d->digitStr, p, &d->points, false);
else
@@ -1070,7 +1074,7 @@ void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter
q->objectName().toLocal8Bit().constData(), segmentNo);
}
// End exact copy
- p.setPen(fgColor);
+ p.setPen(Qt::NoPen);
p.setBrush(fgColor);
p.drawPolygon(a);
p.setBrush(Qt::NoBrush);
@@ -1218,8 +1222,8 @@ void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter
\header \i Style \i Result
\row \i \c Outline
\i Produces raised segments filled with the background color
- (this is the default).
\row \i \c Filled
+ (this is the default).
\i Produces raised segments filled with the foreground color.
\row \i \c Flat
\i Produces flat segments filled with the foreground color.
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index a95d2f2..1778308 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -79,7 +79,7 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include "qkeysequence.h"
-#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1String("\t") + QString(QKeySequence(k)) : QString())
+#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString())
#else
#define ACCEL_KEY(k) QString()
#endif
@@ -2571,7 +2571,7 @@ void QLineEdit::paintEvent(QPaintEvent *)
// draw text, selections and cursors
#ifndef QT_NO_STYLE_STYLESHEET
if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style())) {
- cssStyle->focusPalette(this, &panel, &pal);
+ cssStyle->styleSheetPalette(this, &panel, &pal);
}
#endif
p.setPen(pal.text().color());
@@ -3577,6 +3577,8 @@ void QLineEditPrivate::redo() {
case RemoveSelection:
case DeleteSelection:
text.remove(cmd.pos, 1);
+ selstart = cmd.selStart;
+ selend = cmd.selEnd;
cursor = cmd.pos;
break;
case Separator:
diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm
index c807afb..53e1ad5 100644
--- a/src/gui/widgets/qmainwindowlayout_mac.mm
+++ b/src/gui/widgets/qmainwindowlayout_mac.mm
@@ -502,11 +502,11 @@ void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const
QMacCocoaAutoReleasePool pool;
QWidgetItem layoutItem(tb);
QSize size = layoutItem.maximumSize();
- NSSize nssize = NSMakeSize(size.width(), size.height());
+ NSSize nssize = NSMakeSize(size.width(), size.height() - 2);
[item setMaxSize:nssize];
size = layoutItem.minimumSize();
nssize.width = size.width();
- nssize.height = size.height();
+ nssize.height = size.height() - 2;
[item setMinSize:nssize];
}
}
diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h
index 1159aac..24a58a6 100644
--- a/src/gui/widgets/qmainwindowlayout_p.h
+++ b/src/gui/widgets/qmainwindowlayout_p.h
@@ -341,34 +341,4 @@ QT_END_NAMESPACE
#endif // QT_NO_MAINWINDOW
-QT_BEGIN_NAMESPACE
-static inline int pick(Qt::Orientation o, const QPoint &pos)
-{ return o == Qt::Horizontal ? pos.x() : pos.y(); }
-
-static inline int pick(Qt::Orientation o, const QSize &size)
-{ return o == Qt::Horizontal ? size.width() : size.height(); }
-
-static inline int &rpick(Qt::Orientation o, QPoint &pos)
-{ return o == Qt::Horizontal ? pos.rx() : pos.ry(); }
-
-static inline int &rpick(Qt::Orientation o, QSize &size)
-{ return o == Qt::Horizontal ? size.rwidth() : size.rheight(); }
-
-static inline QSizePolicy::Policy pick(Qt::Orientation o, const QSizePolicy &policy)
-{ return o == Qt::Horizontal ? policy.horizontalPolicy() : policy.verticalPolicy(); }
-
-static inline int perp(Qt::Orientation o, const QPoint &pos)
-{ return o == Qt::Vertical ? pos.x() : pos.y(); }
-
-static inline int perp(Qt::Orientation o, const QSize &size)
-{ return o == Qt::Vertical ? size.width() : size.height(); }
-
-static inline int &rperp(Qt::Orientation o, QPoint &pos)
-{ return o == Qt::Vertical ? pos.rx() : pos.ry(); }
-
-static inline int &rperp(Qt::Orientation o, QSize &size)
-{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); }
-
-QT_END_NAMESPACE
-
#endif // QDYNAMICMAINWINDOWLAYOUT_P_H
diff --git a/src/gui/widgets/qmdiarea.cpp b/src/gui/widgets/qmdiarea.cpp
index 6acd977..efaa2d3 100644
--- a/src/gui/widgets/qmdiarea.cpp
+++ b/src/gui/widgets/qmdiarea.cpp
@@ -800,12 +800,12 @@ void QMdiAreaPrivate::appendChild(QMdiSubWindow *child)
Q_Q(QMdiArea);
Q_ASSERT(child && childWindows.indexOf(child) == -1);
- if (child->parent() != q->viewport())
- child->setParent(q->viewport(), child->windowFlags());
+ if (child->parent() != viewport)
+ child->setParent(viewport, child->windowFlags());
childWindows.append(QPointer<QMdiSubWindow>(child));
if (!child->testAttribute(Qt::WA_Resized) && q->isVisible()) {
- QSize newSize(child->sizeHint().boundedTo(q->viewport()->size()));
+ QSize newSize(child->sizeHint().boundedTo(viewport->size()));
child->resize(newSize.expandedTo(qSmartMinSize(child)));
}
@@ -931,7 +931,7 @@ void QMdiAreaPrivate::rearrange(Rearranger *rearranger)
widgets.move(indexToActive, 0);
}
- QRect domain = q->viewport()->rect();
+ QRect domain = viewport->rect();
if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty())
domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count());
@@ -1212,7 +1212,7 @@ void QMdiAreaPrivate::internalRaise(QMdiSubWindow *mdiChild) const
QMdiSubWindow *stackUnderChild = 0;
if (!windowStaysOnTop(mdiChild)) {
- foreach (QObject *object, q_func()->viewport()->children()) {
+ foreach (QObject *object, viewport->children()) {
QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(object);
if (!child || !childWindows.contains(child))
continue;
@@ -1236,7 +1236,7 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in
{
Q_Q(QMdiArea);
if (!minSubWindowSize.isValid() || subWindowCount <= 0)
- return q->viewport()->rect();
+ return viewport->rect();
// Calculate minimum size.
const int columns = qMax(qCeil(qSqrt(qreal(subWindowCount))), 1);
@@ -1255,10 +1255,10 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in
// We don't want sub-subwindows to be placed at the edge, thus add 2 pixels.
int minAreaWidth = minWidth + left + right + 2;
int minAreaHeight = minHeight + top + bottom + 2;
- if (q->horizontalScrollBar()->isVisible())
- minAreaHeight += q->horizontalScrollBar()->height();
- if (q->verticalScrollBar()->isVisible())
- minAreaWidth += q->verticalScrollBar()->width();
+ if (hbar->isVisible())
+ minAreaHeight += hbar->height();
+ if (vbar->isVisible())
+ minAreaWidth += vbar->width();
if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) {
const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q);
minAreaWidth += 2 * frame;
@@ -1268,23 +1268,23 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in
topLevel->resize(topLevel->size() + diff);
}
- QRect domain = q->viewport()->rect();
+ QRect domain = viewport->rect();
// Adjust domain width and provide horizontal scroll bar.
if (domain.width() < minWidth) {
domain.setWidth(minWidth);
- if (q->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff)
+ if (hbarpolicy == Qt::ScrollBarAlwaysOff)
q->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- else if (q->horizontalScrollBar()->value() != 0)
- q->horizontalScrollBar()->setValue(0);
+ else
+ hbar->setValue(0);
}
// Adjust domain height and provide vertical scroll bar.
if (domain.height() < minHeight) {
domain.setHeight(minHeight);
- if (q->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff)
+ if (vbarpolicy == Qt::ScrollBarAlwaysOff)
q->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- else if (q->verticalScrollBar()->value() != 0)
- q->verticalScrollBar()->setValue(0);
+ else
+ vbar->setValue(0);
}
return domain;
}
diff --git a/src/gui/widgets/qmdisubwindow.cpp b/src/gui/widgets/qmdisubwindow.cpp
index 6bf7633..e5cc6b6 100644
--- a/src/gui/widgets/qmdisubwindow.cpp
+++ b/src/gui/widgets/qmdisubwindow.cpp
@@ -1006,7 +1006,7 @@ void QMdiSubWindowPrivate::removeBaseWidget()
Q_Q(QMdiSubWindow);
baseWidget->removeEventFilter(q);
- if (QLayout *layout = q->layout())
+ if (layout)
layout->removeWidget(baseWidget);
if (baseWidget->windowTitle() == q->windowTitle()) {
ignoreWindowTitleChange = true;
@@ -1102,7 +1102,7 @@ void QMdiSubWindowPrivate::updateCursor()
void QMdiSubWindowPrivate::updateDirtyRegions()
{
// No update necessary
- if (!q_func()->parent())
+ if (!parent)
return;
foreach (Operation operation, operationMap.keys())
@@ -1115,7 +1115,7 @@ void QMdiSubWindowPrivate::updateDirtyRegions()
void QMdiSubWindowPrivate::updateGeometryConstraints()
{
Q_Q(QMdiSubWindow);
- if (!q->parent())
+ if (!parent)
return;
internalMinimumSize = (!q->isMinimized() && !q->minimumSize().isNull())
@@ -1145,7 +1145,7 @@ void QMdiSubWindowPrivate::updateMask()
if (!q->mask().isEmpty())
q->clearMask();
- if (!q->parent())
+ if (!parent)
return;
if ((q->isMaximized() && !drawTitleBarWhenMaximized())
@@ -1168,7 +1168,7 @@ void QMdiSubWindowPrivate::setNewGeometry(const QPoint &pos)
{
Q_Q(QMdiSubWindow);
Q_ASSERT(currentOperation != None);
- Q_ASSERT(q->parent());
+ Q_ASSERT(parent);
uint cflags = operationMap.find(currentOperation).value().changeFlags;
int posX = pos.x();
@@ -1235,7 +1235,7 @@ void QMdiSubWindowPrivate::setNewGeometry(const QPoint &pos)
void QMdiSubWindowPrivate::setMinimizeMode()
{
Q_Q(QMdiSubWindow);
- Q_ASSERT(q->parent());
+ Q_ASSERT(parent);
ensureWindowState(Qt::WindowMinimized);
isShadeRequestFromMinimizeMode = true;
@@ -1263,7 +1263,7 @@ void QMdiSubWindowPrivate::setMinimizeMode()
void QMdiSubWindowPrivate::setNormalMode()
{
Q_Q(QMdiSubWindow);
- Q_ASSERT(q->parent());
+ Q_ASSERT(parent);
isShadeMode = false;
isMaximizeMode = false;
@@ -1334,7 +1334,7 @@ void QMdiSubWindowPrivate::setNormalMode()
void QMdiSubWindowPrivate::setMaximizeMode()
{
Q_Q(QMdiSubWindow);
- Q_ASSERT(q->parent());
+ Q_ASSERT(parent);
ensureWindowState(Qt::WindowMaximized);
isShadeMode = false;
@@ -1423,7 +1423,7 @@ void QMdiSubWindowPrivate::setMaximizeMode()
void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus)
{
Q_Q(QMdiSubWindow);
- if (!q->parent() || !activationEnabled)
+ if (!parent || !activationEnabled)
return;
if (activate && !isActive && q->isEnabled()) {
@@ -1711,7 +1711,7 @@ void QMdiSubWindowPrivate::ensureWindowState(Qt::WindowState state)
int QMdiSubWindowPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const
{
Q_Q(const QMdiSubWindow);
- if (!q->parent() || q->windowFlags() & Qt::FramelessWindowHint
+ if (!parent || q->windowFlags() & Qt::FramelessWindowHint
|| (q->isMaximized() && !drawTitleBarWhenMaximized())) {
return 0;
}
@@ -1734,7 +1734,7 @@ void QMdiSubWindowPrivate::sizeParameters(int *margin, int *minWidth) const
{
Q_Q(const QMdiSubWindow);
Qt::WindowFlags flags = q->windowFlags();
- if (!q->parent() || flags & Qt::FramelessWindowHint) {
+ if (!parent || flags & Qt::FramelessWindowHint) {
*margin = 0;
*minWidth = 0;
return;
@@ -1772,7 +1772,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const
if (isChildOfTabbedQMdiArea(q))
return false;
-#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) || defined(Q_OS_WINCE_WM)
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) || defined(Q_WS_WINCE_WM)
return true;
#else
if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q))
@@ -1893,7 +1893,7 @@ void QMdiSubWindowPrivate::enterRubberBandMode()
if (q->isMaximized())
return;
Q_ASSERT(oldGeometry.isValid());
- Q_ASSERT(q->parent());
+ Q_ASSERT(parent);
if (!rubberBand) {
rubberBand = new QRubberBand(QRubberBand::Rectangle, q->parentWidget());
// For accessibility to identify this special widget.
@@ -2079,7 +2079,7 @@ void QMdiSubWindowPrivate::restoreFocus()
void QMdiSubWindowPrivate::setWindowFlags(Qt::WindowFlags windowFlags)
{
Q_Q(QMdiSubWindow);
- if (!q->parent()) {
+ if (!parent) {
q->setWindowFlags(windowFlags);
return;
}
@@ -2164,7 +2164,7 @@ void QMdiSubWindowPrivate::addToSystemMenu(WindowStateAction action, const QStri
QSize QMdiSubWindowPrivate::iconSize() const
{
Q_Q(const QMdiSubWindow);
- if (!q->parent() || q->windowFlags() & Qt::FramelessWindowHint)
+ if (!parent || q->windowFlags() & Qt::FramelessWindowHint)
return QSize(-1, -1);
return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight());
}
@@ -2180,17 +2180,17 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip)
if (!newSizeGrip || sizeGrip || q->windowFlags() & Qt::FramelessWindowHint)
return;
- if (q->layout() && q->layout()->indexOf(newSizeGrip) != -1)
+ if (layout && layout->indexOf(newSizeGrip) != -1)
return;
newSizeGrip->setFixedSize(newSizeGrip->sizeHint());
- bool putSizeGripInLayout = q->layout() ? true : false;
+ bool putSizeGripInLayout = layout ? true : false;
#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
if (qobject_cast<QMacStyle *>(q->style()))
putSizeGripInLayout = false;
#endif
if (putSizeGripInLayout) {
- q->layout()->addWidget(newSizeGrip);
- q->layout()->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight);
+ layout->addWidget(newSizeGrip);
+ layout->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight);
} else {
newSizeGrip->setParent(q);
newSizeGrip->move(q->isLeftToRight() ? q->width() - newSizeGrip->width() : 0,
diff --git a/src/gui/widgets/qmdisubwindow_p.h b/src/gui/widgets/qmdisubwindow_p.h
index 2e672d6..d706546 100644
--- a/src/gui/widgets/qmdisubwindow_p.h
+++ b/src/gui/widgets/qmdisubwindow_p.h
@@ -287,7 +287,7 @@ public:
inline int titleBarHeight() const
{
Q_Q(const QMdiSubWindow);
- if (!q->parent() || q->windowFlags() & Qt::FramelessWindowHint
+ if (!parent || q->windowFlags() & Qt::FramelessWindowHint
|| (q->isMaximized() && !drawTitleBarWhenMaximized())) {
return 0;
}
@@ -308,7 +308,7 @@ public:
inline void setNewGeometry(QRect *geometry)
{
Q_Q(QMdiSubWindow);
- Q_ASSERT(q->parent());
+ Q_ASSERT(parent);
geometry->setSize(geometry->size().expandedTo(internalMinimumSize));
#ifndef QT_NO_RUBBERBAND
if (isInRubberBandMode)
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 6d4dcf2..278a6cd 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -206,7 +206,6 @@ void QMenuPrivate::calcActionRects(QMap<QAction*, QRect> &actionRects, QList<QAc
actionRects.clear();
actionList.clear();
- QList<QAction*> items = filterActions(q->actions());
int max_column_width = 0,
dh = popupGeometry(QApplication::desktop()->screenNumber(q)).height(),
ncols = 1,
@@ -219,6 +218,7 @@ void QMenuPrivate::calcActionRects(QMap<QAction*, QRect> &actionRects, QList<QAc
tabWidth = 0;
maxIconWidth = 0;
hasCheckableItems = false;
+ QList<QAction*> items = filteredActions();
for(int i = 0; i < items.count(); i++) {
QAction *action = items.at(i);
if (widgetItems.value(action))
@@ -349,7 +349,7 @@ void QMenuPrivate::updateActions()
itemsDirty = 0;
}
-QList<QAction *> QMenuPrivate::filterActions(const QList<QAction *> &actions) const
+QList<QAction *> QMenuPrivate::filteredActions() const
{
QList<QAction *> visibleActions;
int i = 0;
@@ -399,9 +399,12 @@ QRect QMenuPrivate::actionRect(QAction *act) const
return ret;
}
+static const qreal MenuFadeTimeInSec = 0.150;
+
void QMenuPrivate::hideUpToMenuBar()
{
Q_Q(QMenu);
+ bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide);
if (!tornoff) {
QWidget *caused = causedPopup.widget;
hideMenu(q); //hide after getting causedPopup
@@ -416,8 +419,9 @@ void QMenuPrivate::hideUpToMenuBar()
if (QMenu *m = qobject_cast<QMenu*>(caused)) {
caused = m->d_func()->causedPopup.widget;
if (!m->d_func()->tornoff)
- hideMenu(m);
- m->d_func()->setCurrentAction(0);
+ hideMenu(m, fadeMenus);
+ if (!fadeMenus) // Mac doesn't clear the action until after hidden.
+ m->d_func()->setCurrentAction(0);
} else {
#ifndef QT_NO_TOOLBUTTON
if (qobject_cast<QToolButton*>(caused) == 0)
@@ -426,26 +430,32 @@ void QMenuPrivate::hideUpToMenuBar()
caused = 0;
}
}
+#if defined(Q_WS_MAC)
+ if (fadeMenus) {
+ QEventLoop eventLoop;
+ QTimer::singleShot(int(MenuFadeTimeInSec * 1000), &eventLoop, SLOT(quit()));
+ QMacWindowFader::currentFader()->performFade();
+ eventLoop.exec();
+ }
+#endif
}
setCurrentAction(0);
}
-void QMenuPrivate::hideMenu(QMenu *menu)
+void QMenuPrivate::hideMenu(QMenu *menu, bool justRegister)
{
if (!menu)
return;
-
#if !defined(QT_NO_EFFECTS)
menu->blockSignals(true);
aboutToHide = true;
// Flash item which is about to trigger (if any).
if (menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)
- && currentAction && currentAction == actionAboutToTrigger) {
-
+ && currentAction && currentAction == actionAboutToTrigger
+ && menu->actions().contains(currentAction)) {
QEventLoop eventLoop;
QAction *activeAction = currentAction;
- // Deselect and wait 60 ms.
menu->setActiveAction(0);
QTimer::singleShot(60, &eventLoop, SLOT(quit()));
eventLoop.exec();
@@ -459,22 +469,24 @@ void QMenuPrivate::hideMenu(QMenu *menu)
// Fade out.
if (menu->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide)) {
// ### Qt 4.4:
- // Should be something like: q->transitionWindow(Qt::FadeOutTransition, 150);
+ // Should be something like: q->transitionWindow(Qt::FadeOutTransition, MenuFadeTimeInSec);
// Hopefully we'll integrate qt/research/windowtransitions into main before 4.4.
// Talk to Richard, Trenton or Bjoern.
#if defined(Q_WS_MAC)
- macWindowFade(qt_mac_window_for(menu)); // FIXME - what is the default duration for view animations
+ if (justRegister) {
+ QMacWindowFader::currentFader()->setFadeDuration(MenuFadeTimeInSec);
+ QMacWindowFader::currentFader()->registerWindowToFade(menu);
+ } else {
+ macWindowFade(qt_mac_window_for(menu), MenuFadeTimeInSec);
+ }
- // Wait for the transition to complete.
- QEventLoop eventLoop;
- QTimer::singleShot(150, &eventLoop, SLOT(quit()));
- eventLoop.exec();
#endif // Q_WS_MAC
}
aboutToHide = false;
menu->blockSignals(false);
#endif // QT_NO_EFFECTS
- menu->hide();
+ if (!justRegister)
+ menu->hide();
}
void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst)
@@ -536,10 +548,12 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
{
Q_Q(QMenu);
tearoffHighlighted = 0;
- if (action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) {
- if(QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
- if(causedPopup.action && menu->d_func()->activeMenu == q)
- menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
+ if (action == currentAction) {
+ if (!action || !action->menu() || action->menu() == activeMenu) {
+ if(QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
+ if(causedPopup.action && menu->d_func()->activeMenu == q)
+ menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
+ }
}
return;
}
@@ -554,7 +568,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
QAction *previousAction = currentAction;
#endif
#ifdef QT3_SUPPORT
- emitHighlighted = (action && action != currentAction);
+ emitHighlighted = action;
#endif
currentAction = action;
if (action) {
@@ -1041,7 +1055,7 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
hideUpToMenuBar();
} else {
- for(QWidget *widget = qApp->activePopupWidget(); widget; ) {
+ for(QWidget *widget = QApplication::activePopupWidget(); widget; ) {
if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
if(qmenu == q)
hideUpToMenuBar();
@@ -1852,7 +1866,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (adjustToDesktop) {
//handle popup falling "off screen"
- if (qApp->layoutDirection() == Qt::RightToLeft) {
+ if (QApplication::layoutDirection() == Qt::RightToLeft) {
if(snapToMouse) //position flowing left from the mouse
pos.setX(mouse.x()-size.width());
@@ -1890,9 +1904,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
setGeometry(QRect(pos, size));
#ifndef QT_NO_EFFECTS
- int hGuess = qApp->layoutDirection() == Qt::RightToLeft ? QEffects::LeftScroll : QEffects::RightScroll;
+ int hGuess = QApplication::layoutDirection() == Qt::RightToLeft ? QEffects::LeftScroll : QEffects::RightScroll;
int vGuess = QEffects::DownScroll;
- if (qApp->layoutDirection() == Qt::RightToLeft) {
+ if (QApplication::layoutDirection() == Qt::RightToLeft) {
if ((snapToMouse && (pos.x() + size.width()/2 > mouse.x())) ||
(qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 > d->causedPopup.widget->x()))
hGuess = QEffects::RightScroll;
@@ -2587,7 +2601,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
{
d->hideMenu(this);
#ifndef QT_NO_MENUBAR
- if (QMenuBar *mb = qobject_cast<QMenuBar*>(qApp->focusWidget())) {
+ if (QMenuBar *mb = qobject_cast<QMenuBar*>(QApplication::focusWidget())) {
mb->d_func()->setKeyboardMode(false);
}
#endif
@@ -2732,7 +2746,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
#ifdef Q_OS_WIN32
if (key_consumed && (e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift || e->key() == Qt::Key_Meta))
- qApp->beep();
+ QApplication::beep();
#endif // Q_OS_WIN32
}
if (key_consumed)
@@ -2864,7 +2878,7 @@ void QMenu::actionEvent(QActionEvent *e)
}
#endif
-#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
+#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
if (!d->wce_menu)
d->wce_menu = new QMenuPrivate::QWceMenuPrivate;
if (e->type() == QEvent::ActionAdded)
diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h
index bf1c39f..d26dd76 100644
--- a/src/gui/widgets/qmenu.h
+++ b/src/gui/widgets/qmenu.h
@@ -149,7 +149,7 @@ public:
OSMenuRef macMenu(OSMenuRef merge=0);
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
HMENU wceMenu(bool create = false);
#endif
@@ -181,7 +181,7 @@ protected:
bool focusNextPrevChild(bool next);
void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
QAction* wceCommands(uint command);
#endif
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index 2560cfa..67656b4 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -71,7 +71,6 @@ QT_BEGIN_NAMESPACE
/*****************************************************************************
QMenu globals
*****************************************************************************/
-bool qt_mac_no_native_menubar = false;
bool qt_mac_no_menubar_merge = false;
bool qt_mac_quit_menu_item_enabled = true;
int qt_mac_menus_open_count = 0;
@@ -143,6 +142,39 @@ static int qt_mac_CountMenuItems(OSMenuRef menu)
return 0;
}
+static quint32 constructModifierMask(quint32 accel_key)
+{
+ quint32 ret = 0;
+ const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
+#ifndef QT_MAC_USE_COCOA
+ if ((accel_key & Qt::ALT) == Qt::ALT)
+ ret |= kMenuOptionModifier;
+ if ((accel_key & Qt::SHIFT) == Qt::SHIFT)
+ ret |= kMenuShiftModifier;
+ if (dontSwap) {
+ if ((accel_key & Qt::META) != Qt::META)
+ ret |= kMenuNoCommandModifier;
+ if ((accel_key & Qt::CTRL) == Qt::CTRL)
+ ret |= kMenuControlModifier;
+ } else {
+ if ((accel_key & Qt::CTRL) != Qt::CTRL)
+ ret |= kMenuNoCommandModifier;
+ if ((accel_key & Qt::META) == Qt::META)
+ ret |= kMenuControlModifier;
+ }
+#else
+ if ((accel_key & Qt::CTRL) == Qt::CTRL)
+ ret |= (dontSwap ? NSControlKeyMask : NSCommandKeyMask);
+ if ((accel_key & Qt::META) == Qt::META)
+ ret |= (dontSwap ? NSCommandKeyMask : NSControlKeyMask);
+ if ((accel_key & Qt::ALT) == Qt::ALT)
+ ret |= NSAlternateKeyMask;
+ if ((accel_key & Qt::SHIFT) == Qt::SHIFT)
+ ret |= NSShiftKeyMask;
+#endif
+ return ret;
+}
+
static bool actualMenuItemVisibility(const QMenuBarPrivate::QMacMenuBarPrivate *mbp,
const QMacMenuAction *action)
{
@@ -166,7 +198,7 @@ bool qt_mac_activate_action(MenuRef menu, uint command, QAction::ActionEvent act
QMenuMergeList *list = 0;
GetMenuItemProperty(menu, 0, kMenuCreatorQt, kMenuPropertyMergeList,
sizeof(list), 0, &list);
- if (!list && qt_mac_current_menubar.qmenubar) {
+ if (!list && qt_mac_current_menubar.qmenubar && qt_mac_current_menubar.qmenubar->isNativeMenuBar()) {
MenuRef apple_menu = qt_mac_current_menubar.qmenubar->d_func()->mac_menubar->apple_menu;
GetMenuItemProperty(apple_menu, 0, kMenuCreatorQt, kMenuPropertyMergeList, sizeof(list), 0, &list);
if (list)
@@ -526,15 +558,7 @@ static bool qt_mac_auto_apple_menu(MenuCommand cmd)
static void qt_mac_get_accel(quint32 accel_key, quint32 *modif, quint32 *key) {
if (modif) {
- *modif = 0;
- if ((accel_key & Qt::CTRL) != Qt::CTRL)
- *modif |= kMenuNoCommandModifier;
- if ((accel_key & Qt::META) == Qt::META)
- *modif |= kMenuControlModifier;
- if ((accel_key & Qt::ALT) == Qt::ALT)
- *modif |= kMenuOptionModifier;
- if ((accel_key & Qt::SHIFT) == Qt::SHIFT)
- *modif |= kMenuShiftModifier;
+ *modif = constructModifierMask(accel_key);
}
accel_key &= ~(Qt::MODIFIER_MASK | Qt::UNICODE_ACCEL);
@@ -599,7 +623,7 @@ static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader()
static NSMenuItem *createNSMenuItem(const QString &title)
{
NSMenuItem *item = [[NSMenuItem alloc]
- initWithTitle:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(title)))
+ initWithTitle:qt_mac_QStringToNSString(title)
action:@selector(qtDispatcherToQAction:) keyEquivalent:@""];
[item setTarget:getMenuLoader()];
return item;
@@ -728,6 +752,18 @@ QMacMenuAction::~QMacMenuAction()
{
#ifdef QT_MAC_USE_COCOA
[menu release];
+ if (action) {
+ QAction::MenuRole role = action->menuRole();
+ // Check if the item is owned by Qt, and should be hidden to keep it from causing
+ // problems. Do it for everything but the quit menu item since that should always
+ // be visible.
+ if (role > QAction::ApplicationSpecificRole && role < QAction::QuitRole) {
+ [menuItem setHidden:YES];
+ } else if (role == QAction::TextHeuristicRole
+ && menuItem != [getMenuLoader() quitMenuItem]) {
+ [menuItem setHidden:YES];
+ }
+ }
[menuItem setTag:nil];
[menuItem release];
#endif
@@ -915,21 +951,22 @@ static QKeySequence qt_mac_menu_merge_accel(QMacMenuAction *action)
ret = action->action->shortcut();
#ifndef QT_MAC_USE_COCOA
else if (action->command == kHICommandPreferences)
- ret = QKeySequence(Qt::CTRL+Qt::Key_Comma);
+ ret = QKeySequence(QKeySequence::Preferences);
else if (action->command == kHICommandQuit)
- ret = QKeySequence(Qt::CTRL+Qt::Key_Q);
+ ret = QKeySequence(QKeySequence::Quit);
#else
else if (action->menuItem == [loader preferencesMenuItem])
- ret = QKeySequence(Qt::CTRL+Qt::Key_Comma);
+ ret = QKeySequence(QKeySequence::Preferences);
else if (action->menuItem == [loader quitMenuItem])
- ret = QKeySequence(Qt::CTRL+Qt::Key_Q);
+ ret = QKeySequence(QKeySequence::Quit);
#endif
return ret;
}
void Q_GUI_EXPORT qt_mac_set_menubar_icons(bool b)
{ QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus, !b); }
-void Q_GUI_EXPORT qt_mac_set_native_menubar(bool b) { qt_mac_no_native_menubar = !b; }
+void Q_GUI_EXPORT qt_mac_set_native_menubar(bool b)
+{ QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, !b); }
void Q_GUI_EXPORT qt_mac_set_menubar_merge(bool b) { qt_mac_no_menubar_merge = !b; }
/*****************************************************************************
@@ -1206,58 +1243,21 @@ QMenuPrivate::QMacMenuPrivate::addAction(QMacMenuAction *action, QMacMenuAction
NSString *keySequenceToKeyEqivalent(const QKeySequence &accel)
{
quint32 accel_key = (accel[0] & ~(Qt::MODIFIER_MASK | Qt::UNICODE_ACCEL));
- unichar keyEquiv[1] = { 0 };
- if (accel_key == Qt::Key_Return)
- keyEquiv[0] = kReturnCharCode;
- else if (accel_key == Qt::Key_Enter)
- keyEquiv[0] = kEnterCharCode;
- else if (accel_key == Qt::Key_Tab)
- keyEquiv[0] = kTabCharCode;
- else if (accel_key == Qt::Key_Backspace)
- keyEquiv[0] = kBackspaceCharCode;
- else if (accel_key == Qt::Key_Delete)
- keyEquiv[0] = NSDeleteFunctionKey;
- else if (accel_key == Qt::Key_Escape)
- keyEquiv[0] = kEscapeCharCode;
- else if (accel_key == Qt::Key_PageUp)
- keyEquiv[0] = NSPageUpFunctionKey;
- else if (accel_key == Qt::Key_PageDown)
- keyEquiv[0] = NSPageDownFunctionKey;
- else if (accel_key == Qt::Key_Up)
- keyEquiv[0] = NSUpArrowFunctionKey;
- else if (accel_key == Qt::Key_Down)
- keyEquiv[0] = NSDownArrowFunctionKey;
- else if (accel_key == Qt::Key_Left)
- keyEquiv[0] = NSLeftArrowFunctionKey;
- else if (accel_key == Qt::Key_Right)
- keyEquiv[0] = NSRightArrowFunctionKey;
- else if (accel_key == Qt::Key_CapsLock)
- keyEquiv[0] = kMenuCapsLockGlyph; // ### Cocoa has no equivalent
- else if (accel_key >= Qt::Key_F1 && accel_key <= Qt::Key_F15)
- keyEquiv[0] = (accel_key - Qt::Key_F1) + NSF1FunctionKey;
- else if (accel_key == Qt::Key_Home)
- keyEquiv[0] = NSHomeFunctionKey;
- else if (accel_key == Qt::Key_End)
- keyEquiv[0] = NSEndFunctionKey;
- else
- keyEquiv[0] = unichar(QChar(accel_key).toLower().unicode());
- return [NSString stringWithCharacters:keyEquiv length:1];
+ extern QChar qt_macSymbolForQtKey(int key); // qkeysequence.cpp
+ QChar keyEquiv = qt_macSymbolForQtKey(accel_key);
+ if (keyEquiv.isNull()) {
+ if (accel_key >= Qt::Key_F1 && accel_key <= Qt::Key_F15)
+ keyEquiv = (accel_key - Qt::Key_F1) + NSF1FunctionKey;
+ else
+ keyEquiv = unichar(QChar(accel_key).toLower().unicode());
+ }
+ return [NSString stringWithCharacters:&keyEquiv.unicode() length:1];
}
// return the cocoa modifier mask for the QKeySequence (currently only looks at the first one).
NSUInteger keySequenceModifierMask(const QKeySequence &accel)
{
- NSUInteger ret = 0;
- quint32 accel_key = accel[0];
- if ((accel_key & Qt::CTRL) == Qt::CTRL)
- ret |= NSCommandKeyMask;
- if ((accel_key & Qt::META) == Qt::META)
- ret |= NSControlKeyMask;
- if ((accel_key & Qt::ALT) == Qt::ALT)
- ret |= NSAlternateKeyMask;
- if ((accel_key & Qt::SHIFT) == Qt::SHIFT)
- ret |= NSShiftKeyMask;
- return ret;
+ return constructModifierMask(accel[0]);
}
void
@@ -1379,18 +1379,18 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action)
// Cocoa Font and title
if (action->action->font().resolve()) {
const QFont &actionFont = action->action->font();
- NSFont *customMenuFont = [NSFont fontWithName:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(actionFont.family())))
+ NSFont *customMenuFont = [NSFont fontWithName:qt_mac_QStringToNSString(actionFont.family())
size:actionFont.pointSize()];
NSArray *keys = [NSArray arrayWithObjects:NSFontAttributeName, nil];
NSArray *objects = [NSArray arrayWithObjects:customMenuFont, nil];
NSDictionary *attributes = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
- NSAttributedString *str = [[[NSAttributedString alloc] initWithString:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(finalString)))
+ NSAttributedString *str = [[[NSAttributedString alloc] initWithString:qt_mac_QStringToNSString(finalString)
attributes:attributes] autorelease];
[item setAttributedTitle: str];
} else {
- [item setTitle: reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(finalString)))];
+ [item setTitle: qt_mac_QStringToNSString(finalString)];
}
- [item setTitle:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(qt_mac_removeMnemonics(text))))];
+ [item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))];
// Cocoa Enabled
[item setEnabled: action->action->isEnabled()];
@@ -1699,7 +1699,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::syncAction(QMacMenuAction *action)
ChangeMenuAttributes(submenu, kMenuAttrHidden, 0);
#else
[item setSubmenu: submenu];
- [submenu setTitle:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(qt_mac_removeMnemonics(action->action->text()))))];
+ [submenu setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(action->action->text()))];
syncNSMenuItemVisiblity(item, visible);
#endif
if (release_submenu) { //no pointers to it
@@ -1733,9 +1733,14 @@ QMenuBarPrivate::macCreateMenuBar(QWidget *parent)
{
Q_Q(QMenuBar);
static int checkEnv = -1;
+ // We call the isNativeMenuBar function here
+ // becasue that will make sure that local overrides
+ // are dealt with correctly.
+ bool qt_mac_no_native_menubar = !q->isNativeMenuBar();
if (qt_mac_no_native_menubar == false && checkEnv < 0) {
checkEnv = !qgetenv("QT_MAC_NO_NATIVE_MENUBAR").isEmpty();
- qt_mac_no_native_menubar = checkEnv;
+ QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, checkEnv);
+ qt_mac_no_native_menubar = !q->isNativeMenuBar();
}
if (!qt_mac_no_native_menubar) {
extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp
@@ -1770,7 +1775,7 @@ void QMenuBarPrivate::macDestroyMenuBar()
OSMenuRef QMenuBarPrivate::macMenu()
{
Q_Q(QMenuBar);
- if (!mac_menubar) {
+ if (!q->isNativeMenuBar() || !mac_menubar) {
return 0;
} else if (!mac_menubar->menu) {
mac_menubar->menu = qt_mac_create_menu(q);
@@ -1786,7 +1791,7 @@ OSMenuRef QMenuBarPrivate::macMenu()
SetMenuItemHierarchicalMenu(mac_menubar->menu, index, mac_menubar->apple_menu);
SetMenuItemProperty(mac_menubar->apple_menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(q), &q);
#else
- [mac_menubar->apple_menu setTitle:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(QString(QChar(0x14)))))];
+ [mac_menubar->apple_menu setTitle:qt_mac_QStringToNSString(QString(QChar(0x14)))];
NSMenuItem *apple_menuItem = [[NSMenuItem alloc] init];
[apple_menuItem setSubmenu:mac_menubar->menu];
[mac_menubar->apple_menu addItem:apple_menuItem];
@@ -1829,6 +1834,9 @@ OSMenuRef QMenuBar::macMenu() { return d_func()->macMenu(); }
*/
static bool qt_mac_is_ancestor(QWidget* possibleAncestor, QWidget *child)
{
+ if (!possibleAncestor)
+ return false;
+
QWidget * current = child->parentWidget();
while (current != 0) {
if (current == possibleAncestor)
@@ -1847,22 +1855,19 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget)
{
if (modalWidget == 0 || menuBar == 0)
return false;
- const Qt::WindowModality modality = modalWidget->windowModality();
- if (modality == Qt::ApplicationModal) {
- return true;
- } else if (modality == Qt::WindowModal) {
- QWidget * parent = menuBar->parentWidget();
-
- // Special case for the global menu bar: It's not associated
- // with a window so don't disable it.
- if (parent == 0)
- return false;
- // Disable menu entries in menu bars that belong to ancestors of
- // the modal widget, leave entries in unrelated menu bars enabled.
- return qt_mac_is_ancestor(parent, modalWidget);
+ // If there is an application modal window on
+ // screen, the entries of the menubar should be disabled:
+ QWidget *w = modalWidget;
+ while (w) {
+ if (w->isVisible() && w->windowModality() == Qt::ApplicationModal)
+ return true;
+ w = w->parentWidget();
}
- return false; // modality == NonModal
+
+ // INVARIANT: modalWidget is window modal. Disable menu entries
+ // if the menu bar belongs to an ancestor of modalWidget:
+ return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget);
}
static void cancelAllMenuTracking()
@@ -1891,9 +1896,6 @@ static void cancelAllMenuTracking()
*/
bool QMenuBar::macUpdateMenuBar()
{
- if (qt_mac_no_native_menubar) //nothing to be done..
- return true;
-
cancelAllMenuTracking();
QMenuBar *mb = 0;
//find a menu bar
@@ -1927,7 +1929,7 @@ bool QMenuBar::macUpdateMenuBar()
mb = fallback;
//now set it
bool ret = false;
- if (mb) {
+ if (mb && mb->isNativeMenuBar()) {
#ifdef QT_MAC_USE_COCOA
QMacCocoaAutoReleasePool pool;
#endif
@@ -1965,7 +1967,7 @@ bool QMenuBar::macUpdateMenuBar()
qt_mac_current_menubar.qmenubar = mb;
qt_mac_current_menubar.modal = QApplicationPrivate::modalState();
ret = true;
- } else if (qt_mac_current_menubar.qmenubar) {
+ } else if (qt_mac_current_menubar.qmenubar && qt_mac_current_menubar.qmenubar->isNativeMenuBar()) {
const bool modal = QApplicationPrivate::modalState();
if (modal != qt_mac_current_menubar.modal) {
ret = true;
diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
index aafc945..d5674c8 100644
--- a/src/gui/widgets/qmenu_p.h
+++ b/src/gui/widgets/qmenu_p.h
@@ -115,7 +115,7 @@ struct QMenuMergeItem
typedef QList<QMenuMergeItem> QMenuMergeList;
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
struct QWceMenuAction {
uint command;
QPointer<QAction> action;
@@ -144,7 +144,7 @@ public:
#ifdef Q_WS_MAC
,mac_menu(0)
#endif
-#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
+#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
,wce_menu(0)
#endif
#ifdef Q_OS_SYMBIAN
@@ -160,7 +160,7 @@ public:
#ifdef Q_WS_MAC
delete mac_menu;
#endif
-#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
+#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
delete wce_menu;
#endif
#ifdef Q_OS_SYMBIAN
@@ -180,7 +180,7 @@ public:
void calcActionRects(QMap<QAction*, QRect> &actionRects, QList<QAction*> &actionList) const;
void updateActions();
QRect popupGeometry(int screen=-1) const;
- QList<QAction *> filterActions(const QList<QAction *> &actions) const;
+ QList<QAction *> filteredActions() const;
uint ncols : 4; //4 bits is probably plenty
uint collapsibleSeparators : 1;
@@ -239,7 +239,7 @@ public:
virtual QList<QPointer<QWidget> > calcCausedStack() const;
QMenuCaused causedPopup;
void hideUpToMenuBar();
- void hideMenu(QMenu *menu);
+ void hideMenu(QMenu *menu, bool justRegister = false);
//index mappings
inline QAction *actionAt(int i) const { return q_func()->actions().at(i); }
@@ -312,7 +312,7 @@ public:
bool emitHighlighted;
#endif
-#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
+#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
struct QWceMenuPrivate {
QList<QWceMenuAction*> actionItems;
HMENU menuHandle;
diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp
index 42a4e0b..2ce89f9 100644
--- a/src/gui/widgets/qmenu_wince.cpp
+++ b/src/gui/widgets/qmenu_wince.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
//Native menubars are only supported for Windows Mobile not the standard SDK/generic WinCE
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#include "qmenu.h"
#include "qt_windows.h"
#include "qapplication.h"
@@ -621,4 +621,4 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() {
QT_END_NAMESPACE
#endif //QT_NO_MENUBAR
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index fb8a69b..09742d2 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -67,7 +67,7 @@
#include "qmenubar_p.h"
#include "qdebug.h"
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp
#endif
@@ -116,11 +116,9 @@ QSize QMenuBarExtension::sizeHint() const
*/
QAction *QMenuBarPrivate::actionAt(QPoint p) const
{
- Q_Q(const QMenuBar);
- QList<QAction*> items = q->actions();
- for(int i = 0; i < items.size(); ++i) {
- if(actionRect(items.at(i)).contains(p))
- return items.at(i);
+ for(int i = 0; i < actions.size(); ++i) {
+ if(actionRect(actions.at(i)).contains(p))
+ return actions.at(i);
}
return 0;
}
@@ -194,7 +192,7 @@ void QMenuBarPrivate::updateGeometries()
}
#ifdef Q_WS_MAC
- if(mac_menubar) {//nothing to see here folks, move along..
+ if(q->isNativeMenuBar()) {//nothing to see here folks, move along..
itemsDirty = false;
return;
}
@@ -220,7 +218,8 @@ void QMenuBarPrivate::updateGeometries()
//we try to see if the actions will fit there
bool hasHiddenActions = false;
- foreach(QAction *action, actionList) {
+ for (int i = 0; i < actionList.count(); ++i) {
+ QAction *action = actionList.at(i);
if (!menuRect.contains(actionRect(action))) {
hasHiddenActions = true;
break;
@@ -230,7 +229,8 @@ void QMenuBarPrivate::updateGeometries()
//...and if not, determine the ones that fit on the menu with the extension visible
if (hasHiddenActions) {
menuRect = this->menuRect(true);
- foreach(QAction *action, actionList) {
+ for (int i = 0; i < actionList.count(); ++i) {
+ QAction *action = actionList.at(i);
if (!menuRect.contains(actionRect(action))) {
hiddenActions.append(action);
}
@@ -257,9 +257,9 @@ void QMenuBarPrivate::updateGeometries()
}
q->updateGeometry();
#ifdef QT3_SUPPORT
- if (q->parentWidget() != 0) {
+ if (parent) {
QMenubarUpdatedEvent menubarUpdated(q);
- QApplication::sendEvent(q->parentWidget(), &menubarUpdated);
+ QApplication::sendEvent(parent, &menubarUpdated);
}
#endif
}
@@ -282,7 +282,7 @@ void QMenuBarPrivate::setKeyboardMode(bool b)
}
keyboardState = b;
if(b) {
- QWidget *fw = qApp->focusWidget();
+ QWidget *fw = QApplication::focusWidget();
if (fw != q)
keyboardFocusWidget = fw;
if(!currentAction && !actionList.isEmpty())
@@ -292,7 +292,7 @@ void QMenuBarPrivate::setKeyboardMode(bool b)
if(!popupState)
setCurrentAction(0);
if(keyboardFocusWidget) {
- if (qApp->focusWidget() == q)
+ if (QApplication::focusWidget() == q)
keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason);
keyboardFocusWidget = 0;
}
@@ -411,15 +411,14 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start, QMap<QAction*, Q
actionList.clear();
const int itemSpacing = q->style()->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q);
int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0;
- QList<QAction*> items = q->actions();
//calculate size
const QFontMetrics fm = q->fontMetrics();
const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q),
vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q),
icone = q->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
- for(int i = 0; i < items.count(); i++) {
- QAction *action = items.at(i);
+ for(int i = 0; i < actions.count(); i++) {
+ QAction *action = actions.at(i);
if(!action->isVisible())
continue;
@@ -532,7 +531,6 @@ void QMenuBarPrivate::_q_actionHovered()
emit q->hovered(action);
#ifndef QT_NO_ACCESSIBILITY
if (QAccessible::isActive()) {
- QList<QAction*> actions = q->actions();
int actionIndex = actions.indexOf(action);
++actionIndex;
QAccessible::updateAccessibility(q, actionIndex, QAccessible::Focus);
@@ -725,7 +723,7 @@ void QMenuBarPrivate::init()
if(mac_menubar)
q->hide();
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
if (qt_wince_is_mobile()) {
wceCreateMenuBar(q->parentWidget());
if(wce_menubar)
@@ -782,7 +780,7 @@ QMenuBar::~QMenuBar()
Q_D(QMenuBar);
d->macDestroyMenuBar();
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
Q_D(QMenuBar);
if (qt_wince_is_mobile())
d->wceDestroyMenuBar();
@@ -1035,14 +1033,8 @@ void QMenuBar::paintEvent(QPaintEvent *e)
*/
void QMenuBar::setVisible(bool visible)
{
-#ifdef Q_WS_MAC
- Q_D(QMenuBar);
- if(d->mac_menubar)
- return;
-#endif
-#ifdef Q_OS_WINCE
- Q_D(QMenuBar);
- if(d->wce_menubar)
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE)
+ if (isNativeMenuBar())
return;
#endif
#ifdef Q_OS_SYMBIAN
@@ -1288,24 +1280,21 @@ void QMenuBar::actionEvent(QActionEvent *e)
{
Q_D(QMenuBar);
d->itemsDirty = true;
+#if defined (Q_WS_MAC) || defined(Q_OS_WINCE)
+ if (isNativeMenuBar()) {
#ifdef Q_WS_MAC
- if(d->mac_menubar) {
- if(e->type() == QEvent::ActionAdded)
- d->mac_menubar->addAction(e->action(), d->mac_menubar->findAction(e->before()));
- else if(e->type() == QEvent::ActionRemoved)
- d->mac_menubar->removeAction(e->action());
- else if(e->type() == QEvent::ActionChanged)
- d->mac_menubar->syncAction(e->action());
- }
+ QMenuBarPrivate::QMacMenuBarPrivate *nativeMenuBar = d->mac_menubar;
+#else
+ QMenuBarPrivate::QWceMenuBarPrivate *nativeMenuBar = d->wce_menubar;
#endif
-#ifdef Q_OS_WINCE
- if(d->wce_menubar) {
+ if (!nativeMenuBar)
+ return;
if(e->type() == QEvent::ActionAdded)
- d->wce_menubar->addAction(e->action(), d->wce_menubar->findAction(e->before()));
+ nativeMenuBar->addAction(e->action(), nativeMenuBar->findAction(e->before()));
else if(e->type() == QEvent::ActionRemoved)
- d->wce_menubar->removeAction(e->action());
+ nativeMenuBar->removeAction(e->action());
else if(e->type() == QEvent::ActionChanged)
- d->wce_menubar->syncAction(e->action());
+ nativeMenuBar->syncAction(e->action());
}
#endif
#ifdef Q_OS_SYMBIAN
@@ -1401,7 +1390,7 @@ void QMenuBarPrivate::handleReparent()
macCreateMenuBar(newParent);
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
if (qt_wince_is_mobile() && wce_menubar)
wce_menubar->rebuild();
#endif
@@ -1644,12 +1633,8 @@ QRect QMenuBar::actionGeometry(QAction *act) const
QSize QMenuBar::minimumSizeHint() const
{
Q_D(const QMenuBar);
-#ifdef Q_WS_MAC
- const bool as_gui_menubar = !d->mac_menubar;
-#elif defined (Q_OS_WINCE)
- const bool as_gui_menubar = !d->wce_menubar;
-#elif defined (Q_OS_SYMBIAN)
- const bool as_gui_menubar = !d->symbian_menubar;
+#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
+ const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
#endif
@@ -1706,16 +1691,13 @@ QSize QMenuBar::minimumSizeHint() const
QSize QMenuBar::sizeHint() const
{
Q_D(const QMenuBar);
-#ifdef Q_WS_MAC
- const bool as_gui_menubar = !d->mac_menubar;
-#elif defined (Q_OS_WINCE)
- const bool as_gui_menubar = !d->wce_menubar;
-#elif defined (Q_OS_SYMBIAN)
- const bool as_gui_menubar = !d->symbian_menubar;
+#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
+ const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
#endif
+
ensurePolished();
QSize ret(0, 0);
const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
@@ -1771,15 +1753,12 @@ QSize QMenuBar::sizeHint() const
int QMenuBar::heightForWidth(int) const
{
Q_D(const QMenuBar);
-#ifdef Q_WS_MAC
- const bool as_gui_menubar = !d->mac_menubar;
-#elif defined (Q_OS_WINCE)
- const bool as_gui_menubar = !d->wce_menubar;
-#elif defined (Q_OS_SYMBIAN)
- const bool as_gui_menubar = !d->symbian_menubar;
+#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
+ const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
#endif
+
int height = 0;
const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
@@ -1894,6 +1873,60 @@ QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const
}
/*!
+ \property QMenuBar::nativeMenuBar
+ \brief Whether or not a menubar will be used as a native menubar on platforms that support it
+ \since 4.6
+
+ This property specifies whether or not the menubar should be used as a native menubar on platforms
+ that support it. The currently supported platforms are Mac OS X and Windows CE. On these platforms
+ if this property is true, the menubar is used in the native menubar and is not in the window of
+ its parent, if false the menubar remains in the window. On other platforms the value of this
+ attribute has no effect.
+
+ The default is to follow whether the Qt::AA_DontUseNativeMenuBar attribute
+ is set for the application. Explicitly settings this property overrides
+ the presence (or abscence) of the attribute.
+*/
+
+void QMenuBar::setNativeMenuBar(bool nativeMenuBar)
+{
+ Q_D(QMenuBar);
+ if (d->nativeMenuBar == -1 || (nativeMenuBar != bool(d->nativeMenuBar))) {
+ d->nativeMenuBar = nativeMenuBar;
+#ifdef Q_WS_MAC
+ if (!d->nativeMenuBar) {
+ extern void qt_mac_clear_menubar();
+ qt_mac_clear_menubar();
+ d->macDestroyMenuBar();
+ const QList<QAction *> &menubarActions = actions();
+ for (int i = 0; i < menubarActions.size(); ++i) {
+ const QAction *action = menubarActions.at(i);
+ if (QMenu *menu = action->menu()) {
+ delete menu->d_func()->mac_menu;
+ menu->d_func()->mac_menu = 0;
+ }
+ }
+ } else {
+ d->macCreateMenuBar(parentWidget());
+ }
+ macUpdateMenuBar();
+ updateGeometry();
+ setVisible(false);
+ setVisible(true);
+#endif
+ }
+}
+
+bool QMenuBar::isNativeMenuBar() const
+{
+ Q_D(const QMenuBar);
+ if (d->nativeMenuBar == -1) {
+ return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar);
+ }
+ return d->nativeMenuBar;
+}
+
+/*!
\since 4.4
Sets the default action to \a act.
@@ -1907,13 +1940,13 @@ QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const
\sa defaultAction()
*/
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
void QMenuBar::setDefaultAction(QAction *act)
{
Q_D(QMenuBar);
if (d->defaultAction == act)
return;
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
if (qt_wince_is_mobile())
if (d->defaultAction) {
disconnect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction()));
@@ -1921,7 +1954,7 @@ void QMenuBar::setDefaultAction(QAction *act)
}
#endif
d->defaultAction = act;
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
if (qt_wince_is_mobile())
if (d->defaultAction) {
connect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction()));
diff --git a/src/gui/widgets/qmenubar.h b/src/gui/widgets/qmenubar.h
index 42f0c0c..58a03ff 100644
--- a/src/gui/widgets/qmenubar.h
+++ b/src/gui/widgets/qmenubar.h
@@ -64,6 +64,7 @@ class Q_GUI_EXPORT QMenuBar : public QWidget
Q_OBJECT
Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
+ Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
public:
explicit QMenuBar(QWidget *parent = 0);
@@ -110,7 +111,7 @@ public:
static bool macUpdateMenuBar();
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
void setDefaultAction(QAction *);
QAction *defaultAction() const;
@@ -118,6 +119,9 @@ public:
static void wceRefresh();
#endif
+ bool isNativeMenuBar() const;
+ void setNativeMenuBar(bool nativeMenuBar);
+
public Q_SLOTS:
virtual void setVisible(bool visible);
@@ -339,7 +343,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int))
Q_PRIVATE_SLOT(d_func(), void _q_updateLayout())
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
Q_PRIVATE_SLOT(d_func(), void _q_updateDefaultAction())
#endif
diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h
index 9e7d511..0421736 100644
--- a/src/gui/widgets/qmenubar_p.h
+++ b/src/gui/widgets/qmenubar_p.h
@@ -57,7 +57,7 @@
#include "QtGui/qstyleoption.h"
#include <private/qmenu_p.h> // Mac needs what in this file!
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#include "qguifunctions_wince.h"
#endif
@@ -77,12 +77,13 @@ class QMenuBarPrivate : public QWidgetPrivate
Q_DECLARE_PUBLIC(QMenuBar)
public:
QMenuBarPrivate() : itemsDirty(0), itemsWidth(0), itemsStart(-1), currentAction(0), mouseDown(0),
- closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0)
+ closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0),
+ nativeMenuBar(-1)
#ifdef Q_WS_MAC
, mac_menubar(0)
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
, wce_menubar(0), wceClassicMenu(false)
#endif
#ifdef Q_OS_SYMBIAN
@@ -95,7 +96,7 @@ public:
#ifdef Q_WS_MAC
delete mac_menubar;
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
delete wce_menubar;
#endif
#ifdef Q_OS_SYMBIAN
@@ -133,6 +134,8 @@ public:
uint keyboardState : 1, altPressed : 1;
QPointer<QWidget> keyboardFocusWidget;
+
+ int nativeMenuBar : 3; // Only has values -1, 0, and 1
//firing of events
void activateAction(QAction *, QAction::ActionEvent);
@@ -141,7 +144,7 @@ public:
void _q_internalShortcutActivated(int);
void _q_updateLayout();
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
void _q_updateDefaultAction();
#endif
@@ -195,7 +198,7 @@ public:
void macDestroyMenuBar();
OSMenuRef macMenu();
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
void wceCreateMenuBar(QWidget *);
void wceDestroyMenuBar();
struct QWceMenuBarPrivate {
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 3d2c4f5..36bac84 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -375,11 +375,16 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block)
extraMargin += fm.width(QChar(0x21B5));
}
tl->beginLayout();
+ qreal availableWidth = d->width;
+ if (availableWidth <= 0) {
+ availableWidth = INT_MAX; // similar to text edit with pageSize.width == 0
+ }
+ availableWidth -= 2*margin + extraMargin;
while (1) {
QTextLine line = tl->createLine();
if (!line.isValid())
break;
- line.setLineWidth(d->width - 2*margin - extraMargin);
+ line.setLineWidth(availableWidth);
height += leading;
line.setPosition(QPointF(margin, height));
@@ -444,7 +449,7 @@ QPlainTextEditControl::QPlainTextEditControl(QPlainTextEdit *parent)
void QPlainTextEditPrivate::_q_cursorPositionChanged()
{
pageUpDownLastCursorYIsValid = false;
-};
+}
void QPlainTextEditPrivate::_q_verticalScrollbarActionTriggered(int action) {
if (action == QAbstractSlider::SliderPageStepAdd) {
@@ -560,7 +565,8 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const {
if (!currentBlock.isValid())
return QRectF();
Q_ASSERT(currentBlock.blockNumber() == currentBlockNumber);
- QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout());
+ QTextDocument *doc = document();
+ QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout());
Q_ASSERT(documentLayout);
QPointF offset;
@@ -571,13 +577,22 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const {
offset.ry() += r.height();
currentBlock = currentBlock.next();
++currentBlockNumber;
+ if (!currentBlock.isVisible()) {
+ currentBlock = doc->findBlockByLineNumber(currentBlock.firstLineNumber());
+ currentBlockNumber = currentBlock.blockNumber();
+ }
r = documentLayout->blockBoundingRect(currentBlock);
}
while (currentBlockNumber > blockNumber && offset.y() >= -textEdit->viewport()->height()) {
currentBlock = currentBlock.previous();
+ --currentBlockNumber;
+ while (!currentBlock.isVisible()) {
+ currentBlock = currentBlock.previous();
+ --currentBlockNumber;
+ }
if (!currentBlock.isValid())
break;
- --currentBlockNumber;
+
r = documentLayout->blockBoundingRect(currentBlock);
offset.ry() -= r.height();
}
@@ -1747,7 +1762,7 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e)
QTextBlock block = firstVisibleBlock();
qreal maximumWidth = document()->documentLayout()->documentSize().width();
-
+
// keep right margin clean from full-width selection
int maxX = offset.x() + qMax((qreal)viewportRect.width(), maximumWidth)
- document()->documentMargin();
diff --git a/src/gui/widgets/qprintpreviewwidget.cpp b/src/gui/widgets/qprintpreviewwidget.cpp
index 80c1271..24d81e0 100644
--- a/src/gui/widgets/qprintpreviewwidget.cpp
+++ b/src/gui/widgets/qprintpreviewwidget.cpp
@@ -99,29 +99,8 @@ void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QRectF paperRect(0,0, paperSize.width(), paperSize.height());
- painter->setClipRect(paperRect & option->exposedRect);
- painter->fillRect(paperRect, Qt::white);
- if (!pagePicture)
- return;
- painter->drawPicture(pageRect.topLeft(), *pagePicture);
-
- // Effect: make anything drawn in the margins look washed out.
- QPainterPath path;
- path.addRect(paperRect);
- path.addRect(pageRect);
- painter->setPen(QPen(Qt::NoPen));
- painter->setBrush(QColor(255, 255, 255, 180));
- painter->drawPath(path);
-
- painter->setClipRect(option->exposedRect);
-#if 0
- // Draw frame around paper.
- painter->setPen(QPen(Qt::black, 0));
- painter->setBrush(Qt::NoBrush);
- painter->drawRect(paperRect);
-#endif
-
// Draw shadow
+ painter->setClipRect(option->exposedRect);
qreal shWidth = paperRect.width()/100;
QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
paperRect.bottomRight() + QPointF(shWidth, 0));
@@ -142,6 +121,27 @@ void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
cgrad.setColorAt(1.0, QColor(0,0,0,0));
painter->fillRect(cshadow, QBrush(cgrad));
+ painter->setClipRect(paperRect & option->exposedRect);
+ painter->fillRect(paperRect, Qt::white);
+ if (!pagePicture)
+ return;
+ painter->drawPicture(pageRect.topLeft(), *pagePicture);
+
+ // Effect: make anything drawn in the margins look washed out.
+ QPainterPath path;
+ path.addRect(paperRect);
+ path.addRect(pageRect);
+ painter->setPen(QPen(Qt::NoPen));
+ painter->setBrush(QColor(255, 255, 255, 180));
+ painter->drawPath(path);
+
+#if 0
+ // Draw frame around paper.
+ painter->setPen(QPen(Qt::black, 0));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawRect(paperRect);
+#endif
+
// todo: drawtext "Page N" below paper
}
diff --git a/src/gui/widgets/qprogressbar.cpp b/src/gui/widgets/qprogressbar.cpp
index 1a7f878..adc3582 100644
--- a/src/gui/widgets/qprogressbar.cpp
+++ b/src/gui/widgets/qprogressbar.cpp
@@ -450,19 +450,19 @@ QString QProgressBar::text() const
qint64 totalSteps = qint64(d->maximum) - qint64(d->minimum);
QString result = d->format;
- result.replace(QLatin1String("%m"), QString::fromLatin1("%1").arg(totalSteps));
- result.replace(QLatin1String("%v"), QString::fromLatin1("%1").arg(d->value));
+ result.replace(QLatin1String("%m"), QString::number(totalSteps));
+ result.replace(QLatin1String("%v"), QString::number(d->value));
// If max and min are equal and we get this far, it means that the
// progress bar has one step and that we are on that step. Return
// 100% here in order to avoid division by zero further down.
if (totalSteps == 0) {
- result.replace(QLatin1String("%p"), QString::fromLatin1("%1").arg(100));
+ result.replace(QLatin1String("%p"), QString::number(100));
return result;
}
int progress = int(((qreal(d->value) - qreal(d->minimum)) * 100.0) / totalSteps);
- result.replace(QLatin1String("%p"), QString::fromLatin1("%1").arg(progress));
+ result.replace(QLatin1String("%p"), QString::number(progress));
return result;
}
diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp
index 03ca751..b526f02 100644
--- a/src/gui/widgets/qpushbutton.cpp
+++ b/src/gui/widgets/qpushbutton.cpp
@@ -527,8 +527,7 @@ void QPushButton::setMenu(QMenu* menu)
return;
if (menu && !d->menu) {
- disconnect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed()));
- connect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed()));
+ connect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed()), Qt::UniqueConnection);
}
if (d->menu)
removeAction(d->menu->menuAction());
@@ -577,7 +576,7 @@ void QPushButtonPrivate::_q_popupPressed()
menu->setNoReplayFor(q);
bool horizontal = true;
#if !defined(QT_NO_TOOLBAR)
- QToolBar *tb = qobject_cast<QToolBar*>(q->parentWidget());
+ QToolBar *tb = qobject_cast<QToolBar*>(parent);
if (tb && tb->orientation() == Qt::Vertical)
horizontal = false;
#endif
@@ -590,7 +589,7 @@ void QPushButtonPrivate::_q_popupPressed()
int x = globalPos.x();
int y = globalPos.y();
if (horizontal) {
- if (globalPos.y() + rect.height() + menuSize.height() <= qApp->desktop()->height()) {
+ if (globalPos.y() + rect.height() + menuSize.height() <= QApplication::desktop()->height()) {
y += rect.height();
} else {
y -= menuSize.height();
@@ -598,7 +597,7 @@ void QPushButtonPrivate::_q_popupPressed()
if (q->layoutDirection() == Qt::RightToLeft)
x += rect.width() - menuSize.width();
} else {
- if (globalPos.x() + rect.width() + menu->sizeHint().width() <= qApp->desktop()->width())
+ if (globalPos.x() + rect.width() + menu->sizeHint().width() <= QApplication::desktop()->width())
x += rect.width();
else
x -= menuSize.width();
diff --git a/src/gui/widgets/qsizegrip.cpp b/src/gui/widgets/qsizegrip.cpp
index 6458b15..244d34a 100644
--- a/src/gui/widgets/qsizegrip.cpp
+++ b/src/gui/widgets/qsizegrip.cpp
@@ -139,7 +139,7 @@ public:
void QSizeGripPrivate::updateMacSizer(bool hide) const
{
Q_Q(const QSizeGrip);
- if (QApplication::closingDown() || !q->parentWidget())
+ if (QApplication::closingDown() || !parent)
return;
QWidget *topLevelWindow = qt_sizegrip_topLevelWidget(const_cast<QSizeGrip *>(q));
if(topLevelWindow && topLevelWindow->isWindow())
diff --git a/src/gui/widgets/qslider.cpp b/src/gui/widgets/qslider.cpp
index 32b9021..5b9c8a4 100644
--- a/src/gui/widgets/qslider.cpp
+++ b/src/gui/widgets/qslider.cpp
@@ -62,7 +62,6 @@ public:
int tickInterval;
QSlider::TickPosition tickPosition;
int clickOffset;
- int snapBackPosition;
void init();
void resetLayoutItemMargins();
int pixelPosToRangeValue(int pos) const;
@@ -493,7 +492,6 @@ void QSlider::mousePressEvent(QMouseEvent *ev)
setRepeatAction(SliderNoAction);
QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
d->clickOffset = d->pick(ev->pos() - sr.topLeft());
- d->snapBackPosition = d->position;
update(sr);
setSliderDown(true);
}
@@ -513,14 +511,6 @@ void QSlider::mouseMoveEvent(QMouseEvent *ev)
int newPosition = d->pixelPosToRangeValue(d->pick(ev->pos()) - d->clickOffset);
QStyleOptionSlider opt;
initStyleOption(&opt);
- int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this);
- if (m >= 0) {
- QRect r = rect();
- r.adjust(-m, -m, m, m);
- if (!r.contains(ev->pos())) {
- newPosition = d->snapBackPosition;
- }
- }
setSliderPosition(newPosition);
}
diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp
index 295bf48..7906022 100644
--- a/src/gui/widgets/qspinbox.cpp
+++ b/src/gui/widgets/qspinbox.cpp
@@ -992,7 +992,7 @@ QVariant QSpinBoxPrivate::valueFromText(const QString &text) const
bool QSpinBoxPrivate::isIntermediateValue(const QString &str) const
{
- const int num = q_func()->locale().toInt(str, 0, 10);
+ const int num = locale.toInt(str, 0, 10);
const int min = minimum.toInt();
const int max = maximum.toInt();
@@ -1039,7 +1039,7 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
{
if (cachedText == input && !input.isEmpty()) {
state = cachedState;
- QSBDEBUG() << "cachedText was" << "'" << cachedText << "'" << "state was "
+ QSBDEBUG() << "cachedText was '" << cachedText << "' state was "
<< state << " and value was " << cachedValue;
return cachedValue;
@@ -1057,18 +1057,18 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
|| (min >= 0 && copy == QLatin1String("+")))) {
state = QValidator::Intermediate;
QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
- } else if (copy.startsWith(QLatin1String("-")) && min >= 0) {
+ } else if (copy.startsWith(QLatin1Char('-')) && min >= 0) {
state = QValidator::Invalid; // special-case -0 will be interpreted as 0 and thus not be invalid with a range from 0-100
} else {
bool ok = false;
bool removedThousand = false;
- num = q_func()->locale().toInt(copy, &ok, 10);
+ num = locale.toInt(copy, &ok, 10);
if (!ok && copy.contains(thousand) && (max >= 1000 || min <= -1000)) {
const int s = copy.size();
copy.remove(thousand);
pos = qMax(0, pos - (s - copy.size()));
removedThousand = true;
- num = q_func()->locale().toInt(copy, &ok, 10);
+ num = locale.toInt(copy, &ok, 10);
}
QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
if (!ok) {
@@ -1263,9 +1263,7 @@ QVariant QDoubleSpinBoxPrivate::valueFromText(const QString &f) const
double QDoubleSpinBoxPrivate::round(double value) const
{
- Q_Q(const QDoubleSpinBox);
- const QString strDbl = q->locale().toString(value, 'f', decimals);
- return q->locale().toDouble(strDbl);
+ return QString::number(value, 'f', decimals).toDouble();
}
@@ -1280,7 +1278,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
{
if (cachedText == input && !input.isEmpty()) {
state = cachedState;
- QSBDEBUG() << "cachedText was" << "'" << cachedText << "'" << "state was "
+ QSBDEBUG() << "cachedText was '" << cachedText << "' state was "
<< state << " and value was " << cachedValue;
return cachedValue;
}
@@ -1357,9 +1355,8 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
{
bool ok = false;
- QLocale loc(q_func()->locale());
- num = loc.toDouble(copy, &ok);
- QSBDEBUG() << __FILE__ << __LINE__ << loc << copy << num << ok;
+ num = locale.toDouble(copy, &ok);
+ QSBDEBUG() << __FILE__ << __LINE__ << locale << copy << num << ok;
bool notAcceptable = false;
if (!ok) {
@@ -1384,7 +1381,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
pos = qMax(0, pos - (s - copy.size()));
- num = loc.toDouble(copy, &ok);
+ num = locale.toDouble(copy, &ok);
QSBDEBUG() << thousand << num << copy << ok;
if (!ok) {
diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp
index 45e838f..24a8b6c 100644
--- a/src/gui/widgets/qsplitter.cpp
+++ b/src/gui/widgets/qsplitter.cpp
@@ -119,7 +119,6 @@ QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
{
Q_D(QSplitterHandle);
d->s = parent;
- d->hover = false;
setOrientation(orientation);
}
@@ -269,8 +268,11 @@ void QSplitterHandle::mouseMoveEvent(QMouseEvent *e)
void QSplitterHandle::mousePressEvent(QMouseEvent *e)
{
Q_D(QSplitterHandle);
- if (e->button() == Qt::LeftButton)
+ if (e->button() == Qt::LeftButton) {
d->mouseOffset = d->pick(e->pos());
+ d->pressed = true;
+ update();
+ }
}
/*!
@@ -285,6 +287,10 @@ void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e)
d->s->setRubberBand(-1);
moveSplitter(pos);
}
+ if (e->button() == Qt::LeftButton) {
+ d->pressed = false;
+ update();
+ }
}
/*!
@@ -303,6 +309,8 @@ void QSplitterHandle::paintEvent(QPaintEvent *)
opt.state = QStyle::State_None;
if (d->hover)
opt.state |= QStyle::State_MouseOver;
+ if (d->pressed)
+ opt.state |= QStyle::State_Sunken;
if (isEnabled())
opt.state |= QStyle::State_Enabled;
parentWidget()->style()->drawControl(QStyle::CE_Splitter, &opt, &p, d->s);
@@ -389,7 +397,7 @@ void QSplitterPrivate::recalc(bool update)
}
if (empty) {
- if (qobject_cast<QSplitter *>(q->parentWidget())) {
+ if (qobject_cast<QSplitter *>(parent)) {
// nested splitters; be nice
maxl = maxt = 0;
} else {
diff --git a/src/gui/widgets/qsplitter_p.h b/src/gui/widgets/qsplitter_p.h
index 5cc43af..9f6fe0c 100644
--- a/src/gui/widgets/qsplitter_p.h
+++ b/src/gui/widgets/qsplitter_p.h
@@ -131,16 +131,17 @@ class QSplitterHandlePrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QSplitterHandle)
public:
- QSplitterHandlePrivate() : orient(Qt::Horizontal), opaq(false), s(0), mouseOffset(0) {}
+ QSplitterHandlePrivate() : s(0), orient(Qt::Horizontal), mouseOffset(0), opaq(false), hover(false), pressed(false) {}
inline int pick(const QPoint &pos) const
{ return orient == Qt::Horizontal ? pos.x() : pos.y(); }
- Qt::Orientation orient;
- bool opaq;
QSplitter *s;
- bool hover;
+ Qt::Orientation orient;
int mouseOffset;
+ bool opaq : 1;
+ bool hover : 1;
+ bool pressed : 1;
};
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qstatusbar.cpp b/src/gui/widgets/qstatusbar.cpp
index c970838..a248346 100644
--- a/src/gui/widgets/qstatusbar.cpp
+++ b/src/gui/widgets/qstatusbar.cpp
@@ -144,7 +144,7 @@ QRect QStatusBarPrivate::messageRect() const
if (rtl)
left = qMax(left, item->w->x() + item->w->width() + 2);
else
- right = qMin(right, item->w->x()-1);
+ right = qMin(right, item->w->x() - 2);
}
break;
}
@@ -728,7 +728,7 @@ void QStatusBar::paintEvent(QPaintEvent *event)
QStatusBarPrivate::SBItem* item = d->items.at(i);
if (item && item->w->isVisible() && (!haveMessage || item->p)) {
QRect ir = item->w->geometry().adjusted(-2, -1, 2, 1);
- if (event->rect().contains(ir)) {
+ if (event->rect().intersects(ir)) {
QStyleOption opt(0);
opt.rect = ir;
opt.palette = palette();
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 785d772..bd8a1b0 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -176,12 +176,11 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
if (tw->cornerWidget(Qt::TopRightCorner) || tw->cornerWidget(Qt::BottomRightCorner))
option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
}
+#endif
QRect textRect = style()->subElementRect(QStyle::SE_TabBarTabText, option, this);
-
option->text = fontMetrics().elidedText(option->text, d->elideMode, textRect.width(),
Qt::TextShowMnemonic);
-#endif
}
/*!
@@ -1944,8 +1943,10 @@ void QTabBar::changeEvent(QEvent *event)
if (event->type() == QEvent::StyleChange) {
d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this));
d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
+ d->refresh();
+ } else if (event->type() == QEvent::FontChange) {
+ d->refresh();
}
- d->refresh();
QWidget::changeEvent(event);
}
diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp
index 43b2f54..c97154c 100644
--- a/src/gui/widgets/qtabwidget.cpp
+++ b/src/gui/widgets/qtabwidget.cpp
@@ -1057,7 +1057,7 @@ void QTabWidget::keyPressEvent(QKeyEvent *e)
break;
}
}
- if (!qApp->focusWidget())
+ if (!QApplication::focusWidget())
d->tabs->setFocus();
} else {
e->ignore();
diff --git a/src/gui/widgets/qtextbrowser.cpp b/src/gui/widgets/qtextbrowser.cpp
index a1f4d34..d849184 100644
--- a/src/gui/widgets/qtextbrowser.cpp
+++ b/src/gui/widgets/qtextbrowser.cpp
@@ -263,7 +263,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
Q_Q(QTextBrowser);
#ifndef QT_NO_CURSOR
if (q->isVisible())
- qApp->setOverrideCursor(Qt::WaitCursor);
+ QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
textOrSourceChanged = true;
@@ -295,9 +295,9 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
if (q->isVisible()) {
QString firstTag = txt.left(txt.indexOf(QLatin1Char('>')) + 1);
- if (firstTag.left(3) == QLatin1String("<qt") && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
+ if (firstTag.startsWith(QLatin1String("<qt")) && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
#ifndef QT_NO_CURSOR
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
#endif
#ifndef QT_NO_WHATSTHIS
QWhatsThis::showText(QCursor::pos(), txt, q);
@@ -342,7 +342,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
#ifndef QT_NO_CURSOR
if (q->isVisible())
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
#endif
emit q->sourceChanged(url);
}
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp
index 1babb6d..7787a66 100644
--- a/src/gui/widgets/qtoolbar.cpp
+++ b/src/gui/widgets/qtoolbar.cpp
@@ -198,7 +198,7 @@ void QToolBarPrivate::initDrag(const QPoint &pos)
if (state != 0)
return;
- QMainWindow *win = qobject_cast<QMainWindow*>(q->parentWidget());
+ QMainWindow *win = qobject_cast<QMainWindow*>(parent);
Q_ASSERT(win != 0);
QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
Q_ASSERT(layout != 0);
@@ -224,7 +224,7 @@ void QToolBarPrivate::startDrag(bool moving)
if ((moving && state->moving) || state->dragging)
return;
- QMainWindow *win = qobject_cast<QMainWindow*>(q->parentWidget());
+ QMainWindow *win = qobject_cast<QMainWindow*>(parent);
Q_ASSERT(win != 0);
QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
Q_ASSERT(layout != 0);
@@ -274,14 +274,16 @@ void QToolBarPrivate::endDrag()
bool QToolBarPrivate::mousePressEvent(QMouseEvent *event)
{
- if (layout->handleRect().contains(event->pos()) == false) {
+ Q_Q(QToolBar);
+ QStyleOptionToolBar opt;
+ q->initStyleOption(&opt);
+ if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) {
#ifdef Q_WS_MAC
- Q_Q(QToolBar);
// When using the unified toolbar on Mac OS X the user can can click and
// drag between toolbar contents to move the window. Make this work by
// implementing the standard mouse-dragging code and then call
// window->move() in mouseMoveEvent below.
- if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->parentWidget())) {
+ if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parent)) {
if (mainWindow->toolBarArea(q) == Qt::TopToolBarArea
&& mainWindow->unifiedTitleAndToolBarOnMac()
&& q->childAt(event->pos()) == 0) {
@@ -335,7 +337,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
return false;
}
- QMainWindow *win = qobject_cast<QMainWindow*>(q->parentWidget());
+ QMainWindow *win = qobject_cast<QMainWindow*>(parent);
if (win == 0)
return true;
@@ -1041,7 +1043,7 @@ void QToolBar::paintEvent(QPaintEvent *)
style->drawControl(QStyle::CE_ToolBar, &opt, &p, this);
}
- opt.rect = d->layout->handleRect();
+ opt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &opt, this);
if (opt.rect.isValid())
style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this);
}
@@ -1142,7 +1144,9 @@ bool QToolBar::event(QEvent *event)
case QEvent::HoverMove: {
#ifndef QT_NO_CURSOR
QHoverEvent *e = static_cast<QHoverEvent*>(event);
- if (d->layout->handleRect().contains(e->pos()))
+ QStyleOptionToolBar opt;
+ initStyleOption(&opt);
+ if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos()))
setCursor(Qt::SizeAllCursor);
else
unsetCursor();
@@ -1153,7 +1157,7 @@ bool QToolBar::event(QEvent *event)
if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
return true;
break;
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
case QEvent::ContextMenu:
{
QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
@@ -1177,7 +1181,7 @@ bool QToolBar::event(QEvent *event)
if (!d->layout->expanded)
break;
- QWidget *w = qApp->activePopupWidget();
+ QWidget *w = QApplication::activePopupWidget();
if (waitForPopup(this, w)) {
d->waitForPopupTimer->start();
break;
@@ -1197,7 +1201,7 @@ void QToolBarPrivate::_q_waitForPopup()
{
Q_Q(QToolBar);
- QWidget *w = qApp->activePopupWidget();
+ QWidget *w = QApplication::activePopupWidget();
if (!waitForPopup(q, w)) {
waitForPopupTimer->stop();
if (!q->underMouse())
diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp
index 49f4a9e..b1b743e 100644
--- a/src/gui/widgets/qtoolbararealayout.cpp
+++ b/src/gui/widgets/qtoolbararealayout.cpp
@@ -113,7 +113,7 @@ QSize QToolBarAreaLayoutLine::sizeHint() const
continue;
QSize sh = item.sizeHint();
- a += pick(o, sh) + item.extraSpace;
+ a += item.preferredSize > 0 ? item.preferredSize : pick(o, sh);
b = qMax(b, perp(o, sh));
}
@@ -163,12 +163,17 @@ void QToolBarAreaLayoutLine::fitLayout()
int itemMin = pick(o, item.minimumSize());
int itemHint = pick(o, item.sizeHint());
//we ensure the extraspace is not too low
- item.extraSpace = qMax(itemMin - itemHint, item.extraSpace);
- itemHint += item.extraSpace;
- int itemExtra = qMin(itemHint - itemMin, extra);
+ item.size = qMax(item.size, itemHint);
+ if (item.preferredSize > 0) {
+ //preferredSize would be the default size
+ item.size = item.preferredSize;
+ }
+
+ //the extraspace is the space above the item minimum sizehint
+ int extraSpace = qMin(item.size - itemMin, extra);
+ item.size = itemMin + extraSpace; //that is the real size
- item.size = itemMin + itemExtra;
- extra -= itemExtra;
+ extra -= extraSpace;
last = i;
}
@@ -395,17 +400,15 @@ void QToolBarAreaLayoutInfo::removeToolBarBreak(QToolBar *before)
void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos)
{
- if (dirty) {
+ if (dirty)
fitLayout();
- }
dirty = true;
- if (o == Qt::Vertical) {
+ if (o == Qt::Vertical)
pos -= rect.top();
- }
- //here we actually update the extraSpace for the line containing the toolbar so that we move it
+ //here we actually update the preferredSize for the line containing the toolbar so that we move it
for (int j = 0; j < lines.count(); ++j) {
QToolBarAreaLayoutLine &line = lines[j];
@@ -432,22 +435,22 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos)
newPos = qMin(pos, maxPos);
}
- //let's update the previous extra space
+ //extra is the number of pixels to add to the previous toolbar
int extra = newPos - current.pos;
- if (qAbs(previous.extraSpace + extra) < QApplication::startDragDistance()) {
- //we stick to the default space
- extra = 0;
+ //we check if the previous is near its size hint
+ //in which case we try to stick to it
+ const int diff = pick(o, previous.sizeHint()) - (previous.size + extra);
+ if (qAbs(diff) < QApplication::startDragDistance()) {
+ //we stick to the default place and size
+ extra += diff;
}
//update for the current item
- current.extraSpace -= extra;
- //this ensures the toolbars to be pushed to the right when necessary
- current.extraSpace = qMax(pick(o,current.minimumSize())- pick(o,current.sizeHint()), current.extraSpace);
-
- if (extra >= 0) {
- previous.extraSpace += extra;
+ current.extendSize(line.o, -extra);
+ if (extra >= 0) {
+ previous.extendSize(line.o, extra);
} else {
//we need to push the toolbars on the left starting with previous
extra = -extra; // we just need to know the number of pixels
@@ -455,13 +458,13 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos)
for(int l = previousIndex; l >=0; --l) {
QToolBarAreaLayoutItem &item = line.toolBarItems[l];
if (!item.skip()) {
- const int minExtraSpace = pick(o, item.minimumSize()) - pick(o, item.sizeHint());
- const int margin = item.extraSpace - minExtraSpace;
+ const int minPreferredSize = pick(o, item.minimumSize());
+ const int margin = item.size - minPreferredSize;
if (margin < extra) {
- item.extraSpace = minExtraSpace;
+ item.resize(line.o, minPreferredSize);
extra -= margin;
} else {
- item.extraSpace -= extra;
+ item.extendSize(line.o, -extra);
extra = 0;
}
}
@@ -536,13 +539,22 @@ bool QToolBarAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *item)
gap_item.gap = true;
gap_item.widgetItem = item;
- //update the previous item's extra space
+ //update the previous item's preferred size
for(int p = k - 1 ; p >= 0; --p) {
QToolBarAreaLayoutItem &previous = line.toolBarItems[p];
if (!previous.skip()) {
//we found the previous one
- gap_item.extraSpace = qMax(0, previous.extraSpace - pick(o, gap_item.sizeHint()));
- previous.extraSpace = qMin(previous.extraSpace, 0);
+ int previousSizeHint = pick(line.o, previous.sizeHint());
+ int previousExtraSpace = previous.size - previousSizeHint;
+
+ if (previousExtraSpace > 0) {
+ //in this case we reset the space
+ previous.preferredSize = -1;
+ previous.size = previousSizeHint;
+
+ gap_item.resize(o, previousExtraSpace);
+ }
+
break;
}
}
@@ -1132,15 +1144,22 @@ QLayoutItem *QToolBarAreaLayout::unplug(QList<int> path, QToolBarAreaLayout *oth
//update the leading space here
QToolBarAreaLayoutInfo &info = docks[path.at(0)];
QToolBarAreaLayoutLine &line = info.lines[path.at(1)];
- if (item.extraSpace != 0) {
+ if (item.size != pick(line.o, item.realSizeHint())) {
+ //the item doesn't have its default size
+ //so we'll give this to the next item
int newExtraSpace = 0;
+ //let's iterate over the siblings of the current item that pare placed before it
+ //we need to find just the one before
for (int i = path.at(2) - 1; i >= 0; --i) {
QToolBarAreaLayoutItem &previous = line.toolBarItems[i];
if (!previous.skip()) {
+ //we need to check if it has a previous element and a next one
+ //the previous will get its size changed
for (int j = path.at(2) + 1; j < line.toolBarItems.count(); ++j) {
const QToolBarAreaLayoutItem &next = line.toolBarItems.at(j);
if (!next.skip()) {
- newExtraSpace = previous.extraSpace = next.pos - previous.pos - pick(line.o, previous.sizeHint());
+ newExtraSpace = next.pos - previous.pos - pick(line.o, previous.sizeHint());
+ previous.resize(line.o, next.pos - previous.pos);
}
break;
}
@@ -1154,7 +1173,7 @@ QLayoutItem *QToolBarAreaLayout::unplug(QList<int> path, QToolBarAreaLayout *oth
for (int i = path.at(2) - 1; i >= 0; --i) {
QToolBarAreaLayoutItem &previous = line.toolBarItems[i];
if (!previous.skip()) {
- previous.extraSpace = newExtraSpace;
+ previous.resize(line.o, pick(line.o, previous.sizeHint()) + newExtraSpace);
break;
}
}
@@ -1162,7 +1181,6 @@ QLayoutItem *QToolBarAreaLayout::unplug(QList<int> path, QToolBarAreaLayout *oth
}
}
-
Q_ASSERT(!item.gap);
item.gap = true;
return item.widgetItem;
@@ -1253,8 +1271,8 @@ void QToolBarAreaLayout::saveState(QDataStream &stream) const
}
stream << shownOrientation;
stream << item.pos;
- //if extraSpace is 0 the item has its "normal" size, so no need to store the size (we store -1)
- stream << (item.extraSpace == 0 ? -1 : (pick(line.o, item.realSizeHint()) + item.extraSpace));
+ //we store the preferred size. If the use rdidn't resize the toolbars it will be -1
+ stream << item.preferredSize;
uint geom0, geom1;
packRect(&geom0, &geom1, widget->geometry(), widget->isWindow());
@@ -1339,10 +1357,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
toolBar->setVisible(shown & 1);
toolBar->d_func()->setWindowState(floating, true, rect);
- //if it is -1, it means we should use the default size
- item.extraSpace = (item.size == -1) ? 0 : item.size - pick(line.o, item.realSizeHint());
-
-
+ item.preferredSize = item.size;
line.toolBarItems.append(item);
}
}
diff --git a/src/gui/widgets/qtoolbararealayout_p.h b/src/gui/widgets/qtoolbararealayout_p.h
index 574e366..5662ffc 100644
--- a/src/gui/widgets/qtoolbararealayout_p.h
+++ b/src/gui/widgets/qtoolbararealayout_p.h
@@ -59,6 +59,33 @@
QT_BEGIN_NAMESPACE
+static inline int pick(Qt::Orientation o, const QPoint &pos)
+{ return o == Qt::Horizontal ? pos.x() : pos.y(); }
+
+static inline int pick(Qt::Orientation o, const QSize &size)
+{ return o == Qt::Horizontal ? size.width() : size.height(); }
+
+static inline int &rpick(Qt::Orientation o, QPoint &pos)
+{ return o == Qt::Horizontal ? pos.rx() : pos.ry(); }
+
+static inline int &rpick(Qt::Orientation o, QSize &size)
+{ return o == Qt::Horizontal ? size.rwidth() : size.rheight(); }
+
+static inline QSizePolicy::Policy pick(Qt::Orientation o, const QSizePolicy &policy)
+{ return o == Qt::Horizontal ? policy.horizontalPolicy() : policy.verticalPolicy(); }
+
+static inline int perp(Qt::Orientation o, const QPoint &pos)
+{ return o == Qt::Vertical ? pos.x() : pos.y(); }
+
+static inline int perp(Qt::Orientation o, const QSize &size)
+{ return o == Qt::Vertical ? size.width() : size.height(); }
+
+static inline int &rperp(Qt::Orientation o, QPoint &pos)
+{ return o == Qt::Vertical ? pos.rx() : pos.ry(); }
+
+static inline int &rperp(Qt::Orientation o, QSize &size)
+{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); }
+
#ifndef QT_NO_TOOLBAR
class QToolBar;
@@ -70,17 +97,41 @@ class QToolBarAreaLayoutItem
{
public:
QToolBarAreaLayoutItem(QLayoutItem *item = 0)
- : widgetItem(item), pos(0), size(-1), extraSpace(0), gap(false) {}
+ : widgetItem(item), pos(0), size(-1), preferredSize(-1), gap(false) {}
bool skip() const;
QSize minimumSize() const;
QSize sizeHint() const;
- QSize realSizeHint() const;
+ QSize realSizeHint() const;
+
+ void resize(Qt::Orientation o, int newSize)
+ {
+ newSize = qMax(pick(o, minimumSize()), newSize);
+ int sizeh = pick(o, sizeHint());
+ if (newSize == sizeh) {
+ preferredSize = -1;
+ size = sizeh;
+ } else {
+ preferredSize = newSize;
+ }
+ }
+
+ void extendSize(Qt::Orientation o, int extent)
+ {
+ int newSize = qMax(pick(o, minimumSize()), (preferredSize > 0 ? preferredSize : size) + extent);
+ int sizeh = pick(o, sizeHint());
+ if (newSize == sizeh) {
+ preferredSize = -1;
+ size = sizeh;
+ } else {
+ preferredSize = newSize;
+ }
+ }
QLayoutItem *widgetItem;
int pos;
int size;
- int extraSpace;
+ int preferredSize;
bool gap;
};
diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp
index 7771f46..0af2b65 100644
--- a/src/gui/widgets/qtoolbarlayout.cpp
+++ b/src/gui/widgets/qtoolbarlayout.cpp
@@ -128,7 +128,7 @@ void QToolBarLayout::setUsePopupMenu(bool set)
invalidate();
if (!set) {
QObject::connect(extension, SIGNAL(clicked(bool)),
- this, SLOT(setExpanded(bool)));
+ this, SLOT(setExpanded(bool)), Qt::UniqueConnection);
extension->setPopupMode(QToolButton::DelayedPopup);
extension->setMenu(0);
delete popupMenu;
@@ -334,7 +334,7 @@ void QToolBarLayout::updateGeomArray() const
if (QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget()->parentWidget())) {
if (mw->unifiedTitleAndToolBarOnMac()
&& mw->toolBarArea(static_cast<QToolBar *>(parentWidget())) == Qt::TopToolBarArea) {
- if (that->expandFlag) {
+ if (expandFlag) {
tb->setMaximumSize(0xFFFFFF, 0xFFFFFF);
} else {
tb->setMaximumSize(hint);
@@ -360,23 +360,11 @@ void QToolBarLayout::setGeometry(const QRect &rect)
QStyle *style = tb->style();
QStyleOptionToolBar opt;
tb->initStyleOption(&opt);
- const int handleExtent = movable()
- ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0;
const int margin = this->margin();
const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
Qt::Orientation o = tb->orientation();
QLayout::setGeometry(rect);
- if (movable()) {
- if (o == Qt::Horizontal) {
- handRect = QRect(margin, margin, handleExtent, rect.height() - 2*margin);
- handRect = QStyle::visualRect(parentWidget()->layoutDirection(), rect, handRect);
- } else {
- handRect = QRect(margin, margin, rect.width() - 2*margin, handleExtent);
- }
- } else {
- handRect = QRect();
- }
bool ranOutOfSpace = false;
if (!animating)
@@ -742,11 +730,6 @@ QToolBarItem *QToolBarLayout::createItem(QAction *action)
return result;
}
-QRect QToolBarLayout::handleRect() const
-{
- return handRect;
-}
-
QT_END_NAMESPACE
#endif // QT_NO_TOOLBAR
diff --git a/src/gui/widgets/qtoolbarlayout_p.h b/src/gui/widgets/qtoolbarlayout_p.h
index 2eca773..37755b1 100644
--- a/src/gui/widgets/qtoolbarlayout_p.h
+++ b/src/gui/widgets/qtoolbarlayout_p.h
@@ -65,7 +65,7 @@ class QAction;
class QToolBarExtension;
class QMenu;
-class Q_GUI_EXPORT QToolBarItem : public QWidgetItem
+class QToolBarItem : public QWidgetItem
{
public:
QToolBarItem(QWidget *widget);
@@ -75,7 +75,7 @@ public:
bool customWidget;
};
-class Q_GUI_EXPORT QToolBarLayout : public QLayout
+class QToolBarLayout : public QLayout
{
Q_OBJECT
@@ -100,8 +100,6 @@ public:
int indexOf(QAction *action) const;
int indexOf(QWidget *widget) const { return QLayout::indexOf(widget); }
- QRect handleRect() const;
-
bool layoutActions(const QSize &size);
QSize expandedSize(const QSize &size) const;
bool expanded, animating;
diff --git a/src/gui/widgets/qtoolbutton.cpp b/src/gui/widgets/qtoolbutton.cpp
index 7390d04..d26cf5b 100644
--- a/src/gui/widgets/qtoolbutton.cpp
+++ b/src/gui/widgets/qtoolbutton.cpp
@@ -104,10 +104,9 @@ public:
#ifndef QT_NO_MENU
bool QToolButtonPrivate::hasMenu() const
{
- Q_Q(const QToolButton);
return ((defaultAction && defaultAction->menu())
|| (menuAction && menuAction->menu())
- || q->actions().size() > (defaultAction ? 1 : 0));
+ || actions.size() > (defaultAction ? 1 : 0));
}
#endif
@@ -278,7 +277,7 @@ void QToolButtonPrivate::init()
#endif
defaultAction = 0;
#ifndef QT_NO_TOOLBAR
- if (qobject_cast<QToolBar*>(q->parentWidget()))
+ if (qobject_cast<QToolBar*>(parent))
autoRaise = true;
else
#endif
@@ -859,8 +858,7 @@ void QToolButtonPrivate::_q_buttonPressed()
Q_Q(QToolButton);
if (!hasMenu())
return; // no menu to show
-
- if (delay > 0 && popupMode == QToolButton::DelayedPopup)
+ if (delay > 0 && !popupTimer.isActive() && popupMode == QToolButton::DelayedPopup)
popupTimer.start(delay, q);
else if (delay == 0 || popupMode == QToolButton::InstantPopup)
q->showMenu();
@@ -883,7 +881,6 @@ void QToolButtonPrivate::popupTimerDone()
} else {
actualMenu = new QMenu(q);
mustDeleteActualMenu = true;
- QList<QAction*> actions = q->actions();
for(int i = 0; i < actions.size(); i++)
actualMenu->addAction(actions.at(i));
}
@@ -891,12 +888,12 @@ void QToolButtonPrivate::popupTimerDone()
q->setAutoRepeat(false);
bool horizontal = true;
#if !defined(QT_NO_TOOLBAR)
- QToolBar *tb = qobject_cast<QToolBar*>(q->parentWidget());
+ QToolBar *tb = qobject_cast<QToolBar*>(parent);
if (tb && tb->orientation() == Qt::Vertical)
horizontal = false;
#endif
QPoint p;
- QRect screen = qApp->desktop()->availableGeometry(q);
+ QRect screen = QApplication::desktop()->availableGeometry(q);
QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
QRect rect = q->rect();
if (horizontal) {
diff --git a/src/gui/widgets/qvalidator.cpp b/src/gui/widgets/qvalidator.cpp
index 3aca13d..0a7c43c 100644
--- a/src/gui/widgets/qvalidator.cpp
+++ b/src/gui/widgets/qvalidator.cpp
@@ -370,7 +370,7 @@ static int numDigits(qlonglong n)
if (n == 0)
return 1;
return (int)log10(double(n)) + 1;
-};
+}
static qlonglong pow10(int exp)
{
diff --git a/src/gui/widgets/qwidgetresizehandler.cpp b/src/gui/widgets/qwidgetresizehandler.cpp
index 9171244..0e5b28a 100644
--- a/src/gui/widgets/qwidgetresizehandler.cpp
+++ b/src/gui/widgets/qwidgetresizehandler.cpp
@@ -258,7 +258,7 @@ void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e)
#ifdef Q_WS_X11
// Workaround for window managers which refuse to move a tool window partially offscreen.
- QRect desktop = qApp->desktop()->availableGeometry(widget);
+ QRect desktop = QApplication::desktop()->availableGeometry(widget);
pp.rx() = qMax(pp.x(), desktop.left());
pp.ry() = qMax(pp.y(), desktop.top());
p.rx() = qMin(p.x(), desktop.right());