From c2fee8fc6dc679c743d678c58c606ed0323f66aa Mon Sep 17 00:00:00 2001 From: cranphin Date: Sun, 26 Sep 2010 09:29:23 +0000 Subject: [PATCH] GCS: Right, fixed this the right way per suggestion of PeterG (Thanks :) ). Splitters now have 6 pixels of grab area on each side again, without crashing 4.7.0. I still is ugly code, but Qt leaves us no option :) Added some comments to make this clear. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1769 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/plugins/coreplugin/minisplitter.cpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ground/src/plugins/coreplugin/minisplitter.cpp b/ground/src/plugins/coreplugin/minisplitter.cpp index 86b9e58c6..61de7831c 100644 --- a/ground/src/plugins/coreplugin/minisplitter.cpp +++ b/ground/src/plugins/coreplugin/minisplitter.cpp @@ -46,7 +46,6 @@ public: setMask(QRegion(contentsRect())); setAttribute(Qt::WA_MouseNoMask, true); } - void setOrientation(Qt::Orientation orientation); protected: void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); @@ -60,8 +59,20 @@ using namespace Core::Internal; void MiniSplitterHandle::resizeEvent(QResizeEvent *event) { + // Warning: We specifically replace the QSplitterHandle::resizeEvent, + // since there's no way of doing this while still calling it. + // That's because it has pretty much identical code (in 4.7.0) which + // undoes what we do here. And they didn't make that code configurable :) + // This means that with Qt upgrades it's worthwhile to see if anything changed + // in QSplitterHandle::resizeEvent, to see if there's anything important we miss. + + if (orientation() == Qt::Horizontal) + setContentsMargins(6, 0, 6, 0); + else + setContentsMargins(0, 6, 0, 6); setMask(QRegion(contentsRect())); - QSplitterHandle::resizeEvent(event); + + QWidget::resizeEvent(event); } void MiniSplitterHandle::paintEvent(QPaintEvent *event) @@ -70,16 +81,6 @@ void MiniSplitterHandle::paintEvent(QPaintEvent *event) painter.fillRect(event->rect(), Utils::StyleHelper::borderColor()); } - -void MiniSplitterHandle::setOrientation(Qt::Orientation orientation) -{ - QSplitterHandle::setOrientation(orientation); - if (orientation == Qt::Horizontal) - setContentsMargins(6, 0, 6, 0); - else - setContentsMargins(0, 6, 0, 6); -} - QSplitterHandle *MiniSplitter::createHandle() { return new MiniSplitterHandle(orientation(), this);