topic line edit has now a clear button
[quassel.git] / src / qtui / verticaldock.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005/06 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #include "verticaldock.h"
22
23 #include <QPainter>
24
25 #include <QDebug>
26
27 VerticalDockTitle::VerticalDockTitle(QDockWidget *parent)
28   : QWidget(parent)
29 {
30 }
31
32 VerticalDockTitle::~VerticalDockTitle() {
33 }
34
35 QSize VerticalDockTitle::sizeHint() const {
36   return QSize(10, 15);
37 }
38
39 QSize VerticalDockTitle::minimumSizeHint() const {
40   return QSize(10, 15);
41 }
42
43 void VerticalDockTitle::paintEvent(QPaintEvent *event) {
44   Q_UNUSED(event);
45   
46   QPainter painter(this);
47   
48   if(rect().isValid() && rect().height() > minimumSizeHint().height()) {
49     for(int i = 0; i < 2; i++) {
50       QPoint topLeft = rect().topLeft() + QPoint(3 + i*2, 5);
51       QPoint bottomRight = rect().topLeft() + QPoint(3 + i*2, rect().height() - 5);
52       qDrawShadeLine(&painter, topLeft, bottomRight, palette());
53     }
54   }
55   
56 }
57
58
59 // ==============================
60 //  Vertical Dock
61 // ==============================
62 VerticalDock::VerticalDock(const QString &title, QWidget *parent, Qt::WindowFlags flags)
63   : QDockWidget(title, parent, flags)
64 {
65   setDefaultTitleWidget();
66 }
67
68 VerticalDock::VerticalDock(QWidget *parent, Qt::WindowFlags flags)
69   : QDockWidget(parent, flags)
70 {
71   setDefaultTitleWidget();
72 }
73
74 VerticalDock::~VerticalDock() {
75 }
76
77 void VerticalDock::setDefaultTitleWidget() {
78   QWidget *oldDockTitle = titleBarWidget();
79   QWidget *newDockTitle = new VerticalDockTitle(this);
80
81   setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
82   setFeatures(features() | QDockWidget::DockWidgetVerticalTitleBar);
83   setTitleBarWidget(newDockTitle);
84   
85   if(oldDockTitle)
86     oldDockTitle->deleteLater();
87 }