| 1 |
/**************************************************************************************** |
| 2 |
* Copyright (c) 2004 Max Howell <max.howell@methylblue.com> * |
| 3 |
* Copyright (c) 2007 Dan Meltzer <parallelgrapefruit@gmail.com> * |
| 4 |
* Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org> * |
| 5 |
* * |
| 6 |
* This program is free software; you can redistribute it and/or modify it under * |
| 7 |
* the terms of the GNU General Public License as published by the Free Software * |
| 8 |
* Foundation; either version 2 of the License, or (at your option) any later * |
| 9 |
* version. * |
| 10 |
* * |
| 11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * |
| 12 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * |
| 13 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
| 14 |
* * |
| 15 |
* You should have received a copy of the GNU General Public License along with * |
| 16 |
* this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 |
****************************************************************************************/ |
| 18 |
|
| 19 |
#ifndef AMAROKTOOLBAR_H |
| 20 |
#define AMAROKTOOLBAR_H |
| 21 |
|
| 22 |
#include "PaletteHandler.h" |
| 23 |
|
| 24 |
#include <KToolBar> |
| 25 |
|
| 26 |
#include <QPainter> |
| 27 |
#include <QPaintEvent> |
| 28 |
|
| 29 |
namespace Amarok { |
| 30 |
|
| 31 |
class ToolBar : public KToolBar |
| 32 |
{ |
| 33 |
public: |
| 34 |
/** |
| 35 |
* Create a Toolbar with no Border. |
| 36 |
* @param parent The Main Window that |
| 37 |
* this toolbar belongs to. |
| 38 |
* @param name The QObject name of this toolbar |
| 39 |
*/ |
| 40 |
ToolBar( QMainWindow *parent, const char *name ) |
| 41 |
: KToolBar( name, parent, Qt::TopToolBarArea, true, false, false ) |
| 42 |
{ |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Create a borderless toolbar that can live anywhere. |
| 47 |
* @param parent The Widget that should be the parent of this toolbar |
| 48 |
* @param name The QObject name of this toolbar |
| 49 |
*/ |
| 50 |
ToolBar( QWidget *parent ) |
| 51 |
: KToolBar( parent, false, false ) |
| 52 |
{ |
| 53 |
} |
| 54 |
|
| 55 |
protected: |
| 56 |
virtual void paintEvent( QPaintEvent * ) |
| 57 |
{ |
| 58 |
} |
| 59 |
|
| 60 |
}; |
| 61 |
|
| 62 |
class ColoredToolBar : public KToolBar |
| 63 |
{ |
| 64 |
public: |
| 65 |
/** |
| 66 |
* Create a colored Toolbar. |
| 67 |
* @param parent The Main Window that |
| 68 |
* this toolbar belongs to. |
| 69 |
* @param name The QObject name of this toolbar |
| 70 |
*/ |
| 71 |
ColoredToolBar( QMainWindow *parent, const char *name ) |
| 72 |
: KToolBar( name, parent, Qt::TopToolBarArea, true, false, false ) |
| 73 |
{ |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Create a colored toolbar that can live anywhere. |
| 78 |
* @param parent The Widget that should be the parent of this toolbar |
| 79 |
* @param name The QObject name of this toolbar |
| 80 |
*/ |
| 81 |
ColoredToolBar( QWidget *parent ) |
| 82 |
: KToolBar( parent, false, false ) |
| 83 |
{ |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
protected: |
| 88 |
virtual void paintEvent( QPaintEvent * event ) |
| 89 |
{ |
| 90 |
QPainter painter( this ); |
| 91 |
|
| 92 |
painter.setRenderHint( QPainter::Antialiasing ); |
| 93 |
painter.save(); |
| 94 |
|
| 95 |
QColor col = PaletteHandler::highlightColor(); |
| 96 |
qreal radius = 6; |
| 97 |
|
| 98 |
QPainterPath outline; |
| 99 |
outline.addRoundedRect( event->rect(), radius, radius ); |
| 100 |
painter.fillPath( outline, QBrush( col ) ); |
| 101 |
|
| 102 |
painter.restore(); |
| 103 |
} |
| 104 |
}; |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
#endif |