1
/*****************************************************************
3
Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
5
Permission is hereby granted, free of charge, to any person obtaining a copy
6
of this software and associated documentation files (the "Software"), to deal
7
in the Software without restriction, including without limitation the rights
8
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
copies of the Software, and to permit persons to whom the Software is
10
furnished to do so, subject to the following conditions:
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
******************************************************************/
24
#ifndef _plasmautils_h__
25
#define _plasmautils_h__
27
#include <QtCore/QString>
28
#include <QtGui/QColor>
29
#include <QtGui/QIcon>
37
// TODO: these should be moved to a plasma or general definitions header at
38
// some point. they don't belong in utils.h really
39
enum ScreenEdge { NoEdge = 0, TopEdge, TopRightEdge, RightEdge,
40
BottomRightEdge, BottomEdge, BottomLeftEdge, LeftEdge,
42
enum Type { Normal = 0, Stretch };
43
enum Action { About = 1, Help = 2, Preferences = 4, ReportBug = 8 };
44
enum Position { Left = 0, Right, Up, Down, Top = Up, Bottom = Down, Floating };
45
enum Direction { LeftToRight = 0, RightToLeft, TopToBottom, BottomToTop };
46
enum Alignment { LeftTop = 0, Center, RightBottom };
47
enum Size { SizeTiny = 0, SizeSmall, SizeNormal, SizeLarge, SizeCustom };
49
const int XineramaAllScreens = -2;
52
* Given a Qt::ArrotwType return the proper Plasma::Position
54
KDE_EXPORT Position arrowToDirection(Qt::ArrowType p);
57
* For a given Plasma::Position, report which way the popups should be pointing
59
KDE_EXPORT Position popupDirectionForPosition(Position p);
62
* Given a Plasma::Sizes value, returns the size in pixels
64
KDE_EXPORT int sizeValue(Plasma::Size s);
67
* Pixel sizes for but sizes and margins
69
KDE_EXPORT int maxButtonDim();
72
* Tint the image to reflect the current color scheme
73
* Used, for instance, by KMenu side bar
75
KDE_EXPORT void colorize(QImage& image);
78
* Blend two colours together to get a colour halfway in between
80
KDE_EXPORT QColor blendColors(const QColor& c1, const QColor& c2);
83
* Create or copy .desktop files for use in kicker safely and easily
85
KDE_EXPORT QString copyDesktopFile(const KUrl& url);
86
KDE_EXPORT QString newDesktopFile(const KUrl& url);
90
* Reduces a popup menu
92
* When a popup menu contains only 1 sub-menu, it makes no sense to
93
* show this popup-menu but we better show the sub-menu directly.
95
* This function checks whether that is the case and returns either the
96
* original menu or the sub-menu when appropriate.
98
KDE_EXPORT QMenu *reduceMenu(QMenu *);
102
* Calculate the appropriate position for a popup menu based on the
103
* direction, the size of the menu, the widget geometry, and a optional
104
* point in the local coordinates of the widget.
106
KDE_EXPORT QPoint popupPosition(Plasma::Position d,
107
const QWidget* popup,
108
const QWidget* source,
109
const QPoint& offset = QPoint(0, 0));
112
* Calculate an acceptable inverse of the given color which will be used
113
* as the shadow color.
115
KDE_EXPORT QColor shadowColor(const QColor& c);
119
* Get an appropriate for a menu in Plasma. As the user may set this size
120
* globally, it is important to always use this method.
121
* @param icon the name of icon requested
122
* @return the icon set for the requested icon
124
KDE_EXPORT QIcon menuIconSet(const QString& icon);
128
#endif // __pglobal_h__