~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/desktop/applets/kickoff/ui/contentareacap.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2008 Andrew Lake <jamboarder@yahoo.com>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2 of the License, or (at your option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
    Library General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to
 
16
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
    Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#include "contentareacap.h"
 
21
#include <QPainter>
 
22
 
 
23
ContentAreaCap::ContentAreaCap(QWidget *parent, bool flip)
 
24
        :QWidget(parent)
 
25
{
 
26
    setMaximumHeight(3);
 
27
    setMinimumHeight(3);
 
28
    sizePolicy().setVerticalPolicy(QSizePolicy::Fixed);
 
29
    flipCap = flip;
 
30
 
 
31
    parent->setCursor(Qt::ArrowCursor);
 
32
}
 
33
 
 
34
void ContentAreaCap::paintEvent(QPaintEvent *event)
 
35
{
 
36
    Q_UNUSED(event);
 
37
 
 
38
    QPainter painter(this);
 
39
    QPainterPath path;
 
40
    QRect r = rect();
 
41
    if (!flipCap) {
 
42
        path.moveTo(r.topLeft() + QPoint(0,3));
 
43
        path.quadTo(r.topLeft(), r.topLeft() + QPoint(3,0));
 
44
        path.lineTo(r.topRight() + QPoint(-2,0));
 
45
        path.quadTo(r.topRight() + QPoint(1,0), r.topRight() + QPoint(1,3));
 
46
    } else {
 
47
        path.moveTo(r.topLeft());
 
48
        path.quadTo(r.topLeft() + QPoint(0,3), r.topLeft() + QPoint(3,3));
 
49
        path.lineTo(r.topRight() + QPoint(-2,3));
 
50
        path.quadTo(r.topRight() + QPoint(1,3), r.topRight() + QPoint(1,0));
 
51
    }   
 
52
    painter.setPen(QPen(palette().base(), 1));
 
53
    painter.setRenderHint(QPainter::Antialiasing);
 
54
    painter.fillPath(path, palette().base());
 
55
    painter.end();
 
56
}
 
57