summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-10 08:42:47 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-10 08:42:47 (GMT)
commit42d46a85a50926cd24d7216cb99b4084f6d8ad04 (patch)
tree39a79b4709f6da1c04c60a5c3e5adf43c16f6169 /src/gui/widgets
parent37b45fe0415bd6695640b26eb7545280b2e8ffe1 (diff)
parenta863691765b1788a17a67e826f483b68f0f34066 (diff)
downloadQt-42d46a85a50926cd24d7216cb99b4084f6d8ad04.zip
Qt-42d46a85a50926cd24d7216cb99b4084f6d8ad04.tar.gz
Qt-42d46a85a50926cd24d7216cb99b4084f6d8ad04.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qcombobox_p.h2
-rw-r--r--src/gui/widgets/qdockarealayout.cpp46
-rw-r--r--src/gui/widgets/qdockarealayout_p.h4
-rw-r--r--src/gui/widgets/qdockwidget.cpp6
-rw-r--r--src/gui/widgets/qlineedit.cpp10
-rw-r--r--src/gui/widgets/qmenu.cpp4
-rw-r--r--src/gui/widgets/qmenu_mac.mm3
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp8
-rw-r--r--src/gui/widgets/qtabbar.cpp58
-rw-r--r--src/gui/widgets/qtabwidget.cpp2
10 files changed, 99 insertions, 44 deletions
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index 92d85cc..29a628c 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -200,7 +200,9 @@ protected:
menuOpt.menuItemType = QStyleOptionMenuItem::Scroller;
if (sliderAction == QAbstractSlider::SliderSingleStepAdd)
menuOpt.state |= QStyle::State_DownArrow;
+#ifndef Q_WS_S60
p.eraseRect(rect());
+#endif
style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p);
}
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index 806654c..171000b 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -225,7 +225,7 @@ static const int zero = 0;
QDockAreaLayoutInfo::QDockAreaLayoutInfo()
: sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
#ifndef QT_NO_TABBAR
- , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth), tabBarVisible(false)
+ , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)
#endif
{
}
@@ -235,7 +235,7 @@ QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPositio
QMainWindow *window)
: sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
#ifndef QT_NO_TABBAR
- , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)), tabBarVisible(false)
+ , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
#endif
{
#ifdef QT_NO_TABBAR
@@ -296,8 +296,8 @@ QSize QDockAreaLayoutInfo::minimumSize() const
rperp(o, result) = b;
#ifndef QT_NO_TABBAR
- if (tabbed) {
- QSize tbm = tabBarMinimumSize();
+ QSize tbm = tabBarMinimumSize();
+ if (!tbm.isNull()) {
switch (tabBarShape) {
case QTabBar::RoundedNorth:
case QTabBar::RoundedSouth:
@@ -369,8 +369,8 @@ QSize QDockAreaLayoutInfo::maximumSize() const
rperp(o, result) = b;
#ifndef QT_NO_TABBAR
- if (tabbed) {
- QSize tbh = tabBarSizeHint();
+ QSize tbh = tabBarSizeHint();
+ if (!tbh.isNull()) {
switch (tabBarShape) {
case QTabBar::RoundedNorth:
case QTabBar::RoundedSouth:
@@ -1500,7 +1500,7 @@ void QDockAreaLayoutInfo::apply(bool animate)
QRect tab_rect;
QSize tbh = tabBarSizeHint();
- if (tabBarVisible) {
+ if (!tbh.isNull()) {
switch (tabBarShape) {
case QTabBar::RoundedNorth:
case QTabBar::TriangularNorth:
@@ -2079,10 +2079,11 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const
#endif //QT_NO_TABBAR
#ifndef QT_NO_TABBAR
-void QDockAreaLayoutInfo::updateTabBar() const
+//returns whether the tabbar is visible or not
+bool QDockAreaLayoutInfo::updateTabBar() const
{
if (!tabbed)
- return;
+ return false;
QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
@@ -2150,12 +2151,8 @@ void QDockAreaLayoutInfo::updateTabBar() const
tabBar->blockSignals(blocked);
- that->tabBarVisible = ( (gap ? 1 : 0) + tabBar->count()) > 1;
-
- if (changed || !tabBarMin.isValid() | !tabBarHint.isValid()) {
- that->tabBarMin = tabBar->minimumSizeHint();
- that->tabBarHint = tabBar->sizeHint();
- }
+ //returns if the tabbar is visible or not
+ return ( (gap ? 1 : 0) + tabBar->count()) > 1;
}
void QDockAreaLayoutInfo::setTabBarShape(int shape)
@@ -2163,11 +2160,8 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape)
if (shape == tabBarShape)
return;
tabBarShape = shape;
- if (tabBar != 0) {
+ if (tabBar != 0)
tabBar->setShape(static_cast<QTabBar::Shape>(shape));
- tabBarMin = QSize();
- tabBarHint = QSize();
- }
for (int i = 0; i < item_list.count(); ++i) {
QDockAreaLayoutItem &item = item_list[i];
@@ -2178,22 +2172,18 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape)
QSize QDockAreaLayoutInfo::tabBarMinimumSize() const
{
- if (!tabbed)
+ if (!updateTabBar())
return QSize(0, 0);
- updateTabBar();
-
- return tabBarMin;
+ return tabBar->minimumSizeHint();
}
QSize QDockAreaLayoutInfo::tabBarSizeHint() const
{
- if (!tabbed)
+ if (!updateTabBar())
return QSize(0, 0);
- updateTabBar();
-
- return tabBarHint;
+ return tabBar->sizeHint();
}
QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const
@@ -2240,7 +2230,7 @@ QRect QDockAreaLayoutInfo::tabContentRect() const
QRect result = rect;
QSize tbh = tabBarSizeHint();
- if (tabBarVisible) {
+ if (!tbh.isNull()) {
switch (tabBarShape) {
case QTabBar::RoundedNorth:
case QTabBar::TriangularNorth:
diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h
index 0088f00..9cb77ba 100644
--- a/src/gui/widgets/qdockarealayout_p.h
+++ b/src/gui/widgets/qdockarealayout_p.h
@@ -208,11 +208,9 @@ public:
QRect tabContentRect() const;
bool tabbed;
QTabBar *tabBar;
- QSize tabBarMin, tabBarHint;
int tabBarShape;
- bool tabBarVisible;
- void updateTabBar() const;
+ bool updateTabBar() const;
void setTabBarShape(int shape);
QSize tabBarMinimumSize() const;
QSize tabBarSizeHint() const;
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index 54189de..ae00710 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -1270,11 +1270,7 @@ void QDockWidget::setFloating(bool floating)
d->setWindowState(floating, false, floating ? r : QRect());
if (floating && r.isNull()) {
- QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
- QRect titleArea = layout->titleArea();
- int h = layout->verticalTitleBar ? titleArea.width() : titleArea.height();
- QPoint p = mapToGlobal(QPoint(h, h));
- move(p);
+ setAttribute(Qt::WA_Moved, false); //we want it at the default position
}
}
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 655fc61..c1c4abf 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -740,8 +740,14 @@ bool QLineEdit::validateAndSet(const QString &newText, int newPos,
setText(oldText);
return false;
}
- setCursorPosition(newPos);
- setSelection(qMin(newMarkAnchor, newMarkDrag), qAbs(newMarkAnchor - newMarkDrag));
+ int selstart = qMin(newMarkAnchor, newMarkDrag);
+ int sellength = qAbs(newMarkAnchor - newMarkDrag);
+ if (selstart == newPos) {
+ selstart = qMax(newMarkAnchor, newMarkDrag);
+ sellength = -sellength;
+ }
+ //setSelection also set the position
+ setSelection(selstart, sellength);
return true;
}
#endif //QT3_SUPPORT
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 907dd14..f84059d 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -2803,7 +2803,9 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
QAction *action = d->actionAt(e->pos());
if (!action) {
- if (d->hasHadMouse)
+ if (d->hasHadMouse
+ && (!d->currentAction
+ || !(d->currentAction->menu() && d->currentAction->menu()->isVisible())))
d->setCurrentAction(0);
return;
} else if(e->buttons()) {
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index e8400d6..aaa113b 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -2066,6 +2066,7 @@ bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
cancelAllMenuTracking();
QWidget *w = findWindowThatShouldDisplayMenubar();
QMenuBar *mb = findMenubarForWindow(w);
+ extern bool qt_mac_app_fullscreen; //qapplication_mac.mm
// We need to see if we are in full screen mode, if so we need to
// switch the full screen mode to be able to show or hide the menubar.
@@ -2074,12 +2075,14 @@ bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
if(w->isFullScreen()) {
// Ok, switch to showing the menubar when hovering over it.
SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
+ qt_mac_app_fullscreen = true;
}
} else if(w) {
// Removing a menubar
if(w->isFullScreen()) {
// Ok, switch to not showing the menubar when hovering on it
SetSystemUIMode(kUIModeAllHidden, 0);
+ qt_mac_app_fullscreen = true;
}
}
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index 4a9cfed..ab2bdea 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -149,8 +149,12 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe
"Too many menu actions");
const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut);
- QString iconText = action->action->iconText();
- TPtrC menuItemText = qt_QString2TPtrC( underlineShortCut ? action->action->text() : iconText);
+ QString actionText;
+ if (underlineShortCut)
+ actionText = action->action->text().left(CEikMenuPaneItem::SData::ENominalTextLength);
+ else
+ actionText = action->action->iconText().left(CEikMenuPaneItem::SData::ENominalTextLength);
+ TPtrC menuItemText = qt_QString2TPtrC(actionText);
if (action->action->menu()) {
SymbianMenuItem* menuItem = new SymbianMenuItem();
menuItem->menuItemData.iCascadeId = action->command;
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index d03a2f4..d692307 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -67,8 +67,13 @@
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#ifndef QT_NO_STYLE_S60
+#include "qs60style.h"
+#endif
+
QT_BEGIN_NAMESPACE
+
inline static bool verticalTabs(QTabBar::Shape shape)
{
return shape == QTabBar::RoundedWest
@@ -95,9 +100,20 @@ void QTabBarPrivate::updateMacBorderMetrics()
metrics.left = 0;
metrics.right = 0;
qt_mac_updateContentBorderMetricts(window, metrics);
-
- // hide the base line separator if the tabs have docuemnt mode enabled (Cocoa)
- qt_mac_showBaseLineSeparator(window, !documentMode);
+#if QT_MAC_USE_COCOA
+ // In Cocoa we need to keep track of the drawRect method.
+ // If documentMode is enabled we need to change it, unless
+ // a toolbar is present.
+ // Notice that all the information is kept in the window,
+ // that's why we get the private widget for it instead of
+ // the private widget for this widget.
+ QWidgetPrivate *privateWidget = qt_widget_private(q->window());
+ if(privateWidget)
+ privateWidget->changeMethods = documentMode;
+ // Since in Cocoa there is no simple way to remove the baseline, so we just ask the
+ // top level to do the magic for us.
+ privateWidget->syncUnifiedMode();
+#endif // QT_MAC_USE_COCOA
}
#endif
}
@@ -478,6 +494,9 @@ void QTabBarPrivate::layoutTabs()
if (useScrollButtons && tabList.count() && last > available) {
int extra = extraWidth();
+#ifndef QT_NO_STYLE_S60
+ QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style());
+#endif
if (!vertTabs) {
Qt::LayoutDirection ld = q->layoutDirection();
QRect arrows = QStyle::visualRect(ld, q->rect(),
@@ -485,25 +504,57 @@ void QTabBarPrivate::layoutTabs()
int buttonOverlap = q->style()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, q);
if (ld == Qt::LeftToRight) {
+// In S60style, tab scroll buttons are layoutted separately, on the sides of the tabbar.
+#ifndef QT_NO_STYLE_S60
+ if (s60Style) {
+ rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height());
+ leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height());
+ } else {
+#endif
leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
extra/2, arrows.height());
+#ifndef QT_NO_STYLE_S60
+ }
+#endif
leftB->setArrowType(Qt::LeftArrow);
rightB->setArrowType(Qt::RightArrow);
} else {
+#ifndef QT_NO_STYLE_S60
+ if (s60Style) {
+ rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height());
+ leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height());
+ } else {
+#endif
rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
extra/2, arrows.height());
+#ifndef QT_NO_STYLE_S60
+ }
+#endif
rightB->setArrowType(Qt::LeftArrow);
leftB->setArrowType(Qt::RightArrow);
}
} else {
+#ifndef QT_NO_STYLE_S60
+ if (s60Style) {
+ QRect arrows = QRect(0, 0, size.width(), available );
+ leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra / 2);
+ leftB->setArrowType(Qt::UpArrow);
+ rightB->setGeometry(arrows.left(), arrows.bottom() - extra / 2 + 1,
+ arrows.width(), extra / 2);
+ rightB->setArrowType(Qt::DownArrow);
+ } else {
+#endif
QRect arrows = QRect(0, available - extra, size.width(), extra );
leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2);
leftB->setArrowType(Qt::UpArrow);
rightB->setGeometry(arrows.left(), arrows.bottom() - extra/2 + 1,
arrows.width(), extra/2);
rightB->setArrowType(Qt::DownArrow);
+#ifndef QT_NO_STYLE_S60
+ }
+#endif
}
leftB->setEnabled(scrollOffset > 0);
rightB->setEnabled(last - scrollOffset >= available - extra);
@@ -2193,6 +2244,7 @@ bool QTabBar::documentMode() const
void QTabBar::setDocumentMode(bool enabled)
{
Q_D(QTabBar);
+
d->documentMode = enabled;
d->updateMacBorderMetrics();
}
diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp
index 047a905..4a61935 100644
--- a/src/gui/widgets/qtabwidget.cpp
+++ b/src/gui/widgets/qtabwidget.cpp
@@ -542,6 +542,8 @@ void QTabWidget::setTabEnabled(int index, bool enable)
{
Q_D(QTabWidget);
d->tabs->setTabEnabled(index, enable);
+ if (QWidget *widget = d->stack->widget(index))
+ widget->setEnabled(enable);
}
/*!