X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatview.cpp;h=03366c66add69be6f246b97f1b9cb72dc1cd2146;hp=c8116a2778efe3e8ae075e39f027aa4b6de47938;hb=8e9f08aa0f4e663473b634511b1bcc40145e9ba9;hpb=bc77491a09c15f5170d4c1eb9608d5da75e81697 diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index c8116a27..03366c66 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -58,7 +58,7 @@ ChatView::ChatView(MessageFilter *filter, QWidget *parent) void ChatView::init(MessageFilter *filter) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setAlignment(Qt::AlignBottom); + setAlignment(Qt::AlignLeft|Qt::AlignBottom); setInteractive(true); //setOptimizationFlags(QGraphicsView::DontClipPainter | QGraphicsView::DontAdjustForAntialiasing); // setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing); @@ -127,40 +127,15 @@ void ChatView::resizeEvent(QResizeEvent *event) { verticalScrollBar()->setValue(verticalScrollBar()->maximum()); } -// Workaround for QTBUG-6322 -// The viewport rect gets some margins where it shouldn't, resulting in scrollbars to appear void ChatView::adjustSceneRect() { - static qreal voffset = 0; - static bool offsetStable = false; - - QRectF rect = scene()->sceneRect(); - if(rect.height() <= viewport()->height()) { - setSceneRect(rect); - return; - } - if(offsetStable && rect.height() > viewport()->height()) - setSceneRect(rect.adjusted(0, 0, 0, voffset)); - else { - setSceneRect(rect); - - QScrollBar *vbar = verticalScrollBar(); - qreal sceneHeight = rect.height(); - qreal viewHeight = vbar->maximum() + viewport()->height() - vbar->minimum(); - if(sceneHeight != viewHeight) { - voffset = sceneHeight - viewHeight; - // qDebug() << "Adjusting ChatView offset to" << voffset << "(QTBUG-6322)"; - if(sceneHeight + voffset <= viewport()->height()) { - setSceneRect(rect.adjusted(0, -voffset, 0, 0)); - offsetStable = false; - return; - } else - setSceneRect(rect.adjusted(0, 0, 0, voffset)); - } - if(vbar->maximum() + viewport()->height() - vbar->minimum() != sceneHeight) - qWarning() << "Workaround for QTBUG-6322 failed!1!!" << vbar->maximum() + viewport()->height() - vbar->minimum() << sceneHeight; - else - offsetStable = true; - } + // Workaround for QTBUG-6322 + // If the viewport's sceneRect() is (almost) as wide as as the viewport itself, + // Qt wants to reserve space for scrollbars even if they're turned off, resulting in + // an ugly white space at the bottom of the ChatView. + // Since the view's scene's width actually doesn't matter at all, we just adjust it + // by some hopefully large enough value to avoid this problem. + + setSceneRect(scene()->sceneRect().adjusted(0, 0, -25 ,0)); } void ChatView::mouseMoveWhileSelecting(const QPointF &scenePos) {