]> git.sur5r.net Git - minitube/blob - src/minisplitter.cpp
Imported Upstream version 2.3
[minitube] / src / minisplitter.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact:  Qt Software Information (qt-info@nokia.com)
8 **
9 ** Commercial Usage
10 **
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at qt-sales@nokia.com.
27 **
28 **************************************************************************/
29
30 #include "minisplitter.h"
31
32 #include <QPaintEvent>
33 #include <QPainter>
34 #include <QSplitterHandle>
35
36 class MiniSplitterHandle : public QSplitterHandle
37 {
38 public:
39     MiniSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
40             : QSplitterHandle(orientation, parent)
41     {
42         setMask(QRegion(contentsRect()));
43         setAttribute(Qt::WA_MouseNoMask, true);
44     }
45 protected:
46     void resizeEvent(QResizeEvent *event);
47     void paintEvent(QPaintEvent *event);
48 };
49
50 void MiniSplitterHandle::resizeEvent(QResizeEvent *event)
51 {
52     if (orientation() == Qt::Horizontal)
53         setContentsMargins(2, 0, 2, 0);
54     else
55         setContentsMargins(0, 2, 0, 2);
56     setMask(QRegion(contentsRect()));
57     QSplitterHandle::resizeEvent(event);
58 }
59
60 void MiniSplitterHandle::paintEvent(QPaintEvent *event)
61 {
62     QPainter painter(this);
63     painter.fillRect(event->rect(), Qt::black);
64 }
65
66 QSplitterHandle *MiniSplitter::createHandle()
67 {
68     return new MiniSplitterHandle(orientation(), this);
69 }
70
71 MiniSplitter::MiniSplitter(QWidget *parent)
72     : QSplitter(parent)
73 {
74     setHandleWidth(1);
75     setChildrenCollapsible(false);
76     setProperty("minisplitter", true);
77 }
78
79 MiniSplitter::MiniSplitter(Qt::Orientation orientation)
80     : QSplitter(orientation)
81 {
82     setHandleWidth(1);
83     setChildrenCollapsible(false);
84     setProperty("minisplitter", true);
85 }