summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qlistview.cpp8
-rw-r--r--src/widgets/itemviews/qtableview.cpp4
-rw-r--r--src/widgets/itemviews/qtreeview.cpp4
-rw-r--r--src/widgets/widgets/qmainwindow.cpp43
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp8
5 files changed, 43 insertions, 24 deletions
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 8238e5f6d4..135f89d4ac 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -1842,18 +1842,18 @@ void QCommonListViewBase::paintDragDrop(QPainter *painter)
}
#endif
-void QCommonListViewBase::updateHorizontalScrollBar(const QSize & /*step*/)
+void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)
{
+ horizontalScrollBar()->setSingleStep(step.width() + spacing());
horizontalScrollBar()->setPageStep(viewport()->width());
horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width());
- // we do not want to overwrite (a possible user set) single step
}
-void QCommonListViewBase::updateVerticalScrollBar(const QSize & /*step*/)
+void QCommonListViewBase::updateVerticalScrollBar(const QSize &step)
{
+ verticalScrollBar()->setSingleStep(step.height() + spacing());
verticalScrollBar()->setPageStep(viewport()->height());
verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height());
- // we do not want to overwrite (a possible user set) single step
}
void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/)
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 08600b3ef7..a252428a81 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -2170,7 +2170,7 @@ void QTableView::updateGeometries()
} else { // ScrollPerPixel
horizontalScrollBar()->setPageStep(vsize.width());
horizontalScrollBar()->setRange(0, horizontalLength - vsize.width());
- // here we do not want to overwrite (a possible user set) single step
+ horizontalScrollBar()->setSingleStep(qMax(vsize.width() / (columnsInViewport + 1), 2));
}
// vertical scroll bar
@@ -2198,7 +2198,7 @@ void QTableView::updateGeometries()
} else { // ScrollPerPixel
verticalScrollBar()->setPageStep(vsize.height());
verticalScrollBar()->setRange(0, verticalLength - vsize.height());
- // here we do not want to overwrite (a possible user set) single step
+ verticalScrollBar()->setSingleStep(qMax(vsize.height() / (rowsInViewport + 1), 2));
}
d->geometryRecursionBlock = false;
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 4d0eb5c3ad..5d0e835b0e 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -3685,7 +3685,7 @@ void QTreeViewPrivate::updateScrollBars()
}
vbar->setRange(0, contentsHeight - viewportSize.height());
vbar->setPageStep(viewportSize.height());
- // here we do not want to overwrite (a possible user set) single step
+ vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2));
}
const int columnCount = header->count();
@@ -3711,7 +3711,7 @@ void QTreeViewPrivate::updateScrollBars()
viewportSize = maxSize;
hbar->setPageStep(viewportSize.width());
hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0));
- // here we do not want to overwrite (a possible user set) single step
+ hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2));
}
}
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 0638981a9c..07db78c06c 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -60,6 +60,9 @@
#include <private/qwidget_p.h>
#include "qtoolbar_p.h"
#include "qwidgetanimator_p.h"
+#ifdef Q_OS_OSX
+#include <qpa/qplatformnativeinterface.h>
+#endif
#ifdef Q_WS_MAC
#include <private/qt_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
@@ -76,6 +79,9 @@ class QMainWindowPrivate : public QWidgetPrivate
public:
inline QMainWindowPrivate()
: layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly)
+#ifdef Q_OS_OSX
+ , useUnifiedToolBar(false)
+#endif
#ifdef Q_WS_MAC
, useHIToolBar(false)
, activateUnifiedToolbarAfterFullScreen(false)
@@ -88,6 +94,9 @@ public:
QSize iconSize;
bool explicitIconSize;
Qt::ToolButtonStyle toolButtonStyle;
+#ifdef Q_OS_OSX
+ bool useUnifiedToolBar;
+#endif
#ifdef Q_WS_MAC
bool useHIToolBar;
bool activateUnifiedToolbarAfterFullScreen;
@@ -1492,16 +1501,29 @@ bool QMainWindow::event(QEvent *event)
/*!
\property QMainWindow::unifiedTitleAndToolBarOnMac
\brief whether the window uses the unified title and toolbar look on Mac OS X
- \since 4.3
- \obsolete
-
- This property is not implemented in Qt 5. Setting it has no effect.
-
- A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras at
- http://qt.gitorious.org/qtplayground/qtmacextras
+ \since 5.2
*/
void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
{
+#ifdef Q_OS_OSX
+ Q_D(QMainWindow);
+ if (isWindow()) {
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ QPlatformNativeInterface::NativeResourceForIntegrationFunction function =
+ nativeInterface->nativeResourceFunctionForIntegration("setContentBorderThickness");
+ if (!function)
+ return; // Not Cocoa platform plugin.
+
+ createWinId();
+
+ d->useUnifiedToolBar = set;
+
+ const int toolBarHeight = 50;
+ typedef void (*SetContentBorderThicknessFunction)(QWindow *window, int topThickness, int bottomThickness);
+ (reinterpret_cast<SetContentBorderThicknessFunction>(function))(window()->windowHandle(), toolBarHeight, 0);
+ }
+#endif
+
#ifdef Q_WS_MAC
Q_D(QMainWindow);
if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3)
@@ -1534,6 +1556,9 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
bool QMainWindow::unifiedTitleAndToolBarOnMac() const
{
+#ifdef Q_OS_OSX
+ return d_func()->useUnifiedToolBar;
+#endif
#ifdef Q_WS_MAC
return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint);
#endif
@@ -1655,9 +1680,7 @@ QMenu *QMainWindow::createPopupMenu()
for (int i = 0; i < toolbars.size(); ++i) {
QToolBar *toolBar = toolbars.at(i);
if (toolBar->parentWidget() == this
- && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty()
- || (unifiedTitleAndToolBarOnMac()
- && toolBarArea(toolBar) == Qt::TopToolBarArea))) {
+ && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty())) {
menu->addAction(toolbars.at(i)->toggleViewAction());
}
}
diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index 04ef6a80be..5ec76569aa 100644
--- a/src/widgets/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
@@ -655,9 +655,7 @@ QRect QToolBarAreaLayout::fitLayout()
docks[QInternal::BottomDock].rect = QRect(rect.left(), center.bottom() + 1,
rect.width(), bottom_hint.height());
- if (!mainWindow->unifiedTitleAndToolBarOnMac()) {
- docks[QInternal::TopDock].fitLayout();
- }
+ docks[QInternal::TopDock].fitLayout();
docks[QInternal::LeftDock].fitLayout();
docks[QInternal::RightDock].fitLayout();
docks[QInternal::BottomDock].fitLayout();
@@ -1307,8 +1305,6 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
QList<QToolBar*> toolBars = _toolBars;
int lines;
stream >> lines;
- if (!testing)
- testing = mainWindow->unifiedTitleAndToolBarOnMac();
for (int j = 0; j < lines; ++j) {
int pos;
@@ -1319,7 +1315,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
stream >> cnt;
QToolBarAreaLayoutInfo &dock = docks[pos];
- const bool applyingLayout = !testing && !(pos == QInternal::TopDock && mainWindow->unifiedTitleAndToolBarOnMac());
+ const bool applyingLayout = !testing;
QToolBarAreaLayoutLine line(dock.o);
for (int k = 0; k < cnt; ++k) {