Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / libs / plasma / plasma.cpp
blob4b4071ad61e8e518c36e6b2dfae5ad28d4dad3f4
1 /*
2 * Copyright 2005 by Aaron Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include <plasma.h>
22 namespace Plasma
25 qreal scalingFactor(ZoomLevel level)
27 switch (level) {
28 case DesktopZoom:
29 return 1;
30 break;
31 case GroupZoom:
32 return 0.5;
33 break;
34 case OverviewZoom:
35 return 0.2;
36 break;
39 // to make odd compilers not warn like silly beasts
40 return 1;
43 Direction locationToDirection(Location location)
45 switch (location)
47 case Floating:
48 case Desktop:
49 case TopEdge:
50 case FullScreen:
51 //TODO: should we be smarter for floating and planer?
52 // perhaps we should take a QRect and/or QPos as well?
53 return Down;
54 case BottomEdge:
55 return Up;
56 case LeftEdge:
57 return Right;
58 case RightEdge:
59 return Left;
62 return Down;
65 QPainterPath roundedRectangle(const QRectF& rect, qreal radius)
67 QPainterPath path(QPointF(rect.left(), rect.top() + radius));
68 path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner
69 path.lineTo(rect.right() - radius, rect.top()); // Top side
70 path.quadTo(rect.right(), rect.top(), rect.right(), rect.top() + radius); // Top right corner
71 path.lineTo(rect.right(), rect.bottom() - radius); // Right side
72 path.quadTo(rect.right(), rect.bottom(), rect.right() - radius, rect.bottom()); // Bottom right corner
73 path.lineTo(rect.left() + radius, rect.bottom()); // Bottom side
74 path.quadTo(rect.left(), rect.bottom(), rect.left(), rect.bottom() - radius); // Bottom left corner
75 path.closeSubpath();
77 return path;
80 } // Plasma namespace