LP-56 - Better txpid option namings, fix tabs-spaces, tooltips. headers, variable...
[librepilot.git] / ground / openpilotgcs / src / plugins / coreplugin / minisplitter.cpp
blobe5d6316c0e014312b43846781d2ec0c30e41f320
1 /**
2 ******************************************************************************
4 * @file minisplitter.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup CorePlugin Core Plugin
10 * @{
11 * @brief The Core GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "minisplitter.h"
31 #include <utils/stylehelper.h>
33 #include <QPaintEvent>
34 #include <QPainter>
35 #include <QSplitterHandle>
37 namespace Core {
38 namespace Internal {
39 class MiniSplitterHandle : public QSplitterHandle {
40 public:
41 MiniSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
42 : QSplitterHandle(orientation, parent)
44 setMask(QRegion(contentsRect()));
45 setAttribute(Qt::WA_MouseNoMask, true);
47 protected:
48 void resizeEvent(QResizeEvent *event);
49 void paintEvent(QPaintEvent *event);
51 } // namespace Internal
52 } // namespace Core
54 using namespace Core;
55 using namespace Core::Internal;
57 void MiniSplitterHandle::resizeEvent(QResizeEvent *event)
59 // Warning: We specifically replace the QSplitterHandle::resizeEvent,
60 // since there's no way of doing this while still calling it.
61 // That's because it has pretty much identical code (in 4.7.0) which
62 // undoes what we do here. And they didn't make that code configurable :)
63 // This means that with Qt upgrades it's worthwhile to see if anything changed
64 // in QSplitterHandle::resizeEvent, to see if there's anything important we miss.
66 if (orientation() == Qt::Horizontal) {
67 setContentsMargins(6, 0, 6, 0);
68 } else {
69 setContentsMargins(0, 6, 0, 6);
71 setMask(QRegion(contentsRect()));
73 QWidget::resizeEvent(event);
76 void MiniSplitterHandle::paintEvent(QPaintEvent *event)
78 QPainter painter(this);
80 painter.fillRect(event->rect(), Utils::StyleHelper::borderColor());
83 QSplitterHandle *MiniSplitter::createHandle()
85 return new MiniSplitterHandle(orientation(), this);
88 MiniSplitter::MiniSplitter(QWidget *parent)
89 : QSplitter(parent)
91 setHandleWidth(1);
92 setChildrenCollapsible(false);
93 setProperty("minisplitter", true);
96 MiniSplitter::MiniSplitter(Qt::Orientation orientation)
97 : QSplitter(orientation)
99 setHandleWidth(1);
100 setChildrenCollapsible(false);
101 setProperty("minisplitter", true);