diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/qcommandlinkbutton.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/qdockarealayout.cpp | 46 | ||||
-rw-r--r-- | src/gui/widgets/qdockarealayout_p.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/qdockwidget.cpp | 9 |
5 files changed, 27 insertions, 38 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index ca58e6d..e0b09aa 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -56,6 +56,7 @@ #include <qscrollbar.h> #include <qtreeview.h> #include <qheaderview.h> +#include <qmath.h> #ifndef QT_NO_IM #include "qinputcontext.h" #endif @@ -328,7 +329,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const // height - sh.setHeight(qMax(fm.height(), 14) + 2); + sh.setHeight(qMax(qCeil(QFontMetricsF(fm).height()), 14) + 2); if (hasIcon) { sh.setHeight(qMax(sh.height(), iconSize.height() + 2)); } diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp index 6919bc0..e8fe299 100644 --- a/src/gui/widgets/qcommandlinkbutton.cpp +++ b/src/gui/widgets/qcommandlinkbutton.cpp @@ -46,6 +46,7 @@ #include "qtextlayout.h" #include "qcolor.h" #include "qfont.h" +#include <qmath.h> #include "private/qpushbutton_p.h" @@ -242,7 +243,7 @@ int QCommandLinkButtonPrivate::descriptionHeight(int widgetWidth) const } layout.endLayout(); } - return qRound(descriptionheight); + return qCeil(descriptionheight); } /*! 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..11f0a94 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -1269,12 +1269,11 @@ void QDockWidget::setFloating(bool floating) QRect r = d->undockedGeometry; 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); + if (x() < 0 || y() < 0) //may happen if we have been hidden + move(QPoint()); + setAttribute(Qt::WA_Moved, false); //we want it at the default position } } |