1 | /* |
2 | This file is part of the KDE project |
3 | Copyright (C) 2008 David Faure <faure@kde.org> |
4 | Copyright (C) 2009 Christoph Feck <christoph@maxiom.de> |
5 | |
6 | This program is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; see the file COPYING. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #include "konqanimatedlogo_p.h" |
23 | |
24 | #include <KDE/KIconLoader> |
25 | |
26 | #include <QtCore/QEvent> |
27 | #include <QToolBar> |
28 | |
29 | KonqAnimatedLogo::KonqAnimatedLogo(QWidget *parent) |
30 | : KAnimatedButton(parent) |
31 | { |
32 | setAutoRaise(true); |
33 | setFocusPolicy(Qt::NoFocus); |
34 | setToolButtonStyle(Qt::ToolButtonIconOnly); |
35 | QToolBar * bar = qobject_cast<QToolBar *>(parent); |
36 | if (bar) { |
37 | connectToToolBar(bar); |
38 | } |
39 | } |
40 | |
41 | void KonqAnimatedLogo::changeEvent(QEvent *event) |
42 | { |
43 | KAnimatedButton::changeEvent(event); |
44 | if (event->type() == QEvent::ParentAboutToChange) { |
45 | if (parentWidget()) { |
46 | disconnect(parentWidget(), SIGNAL(iconSizeChanged(QSize)), this, SLOT(setAnimatedLogoSize())); |
47 | } |
48 | } else if (event->type() == QEvent::ParentChange) { |
49 | QToolBar *bar = qobject_cast<QToolBar *>(parentWidget()); |
50 | if (bar) { |
51 | connectToToolBar(bar); |
52 | } |
53 | } |
54 | } |
55 | |
56 | void KonqAnimatedLogo::connectToToolBar(QToolBar *bar) |
57 | { |
58 | setAnimatedLogoSize(bar->iconSize()); |
59 | connect(bar, SIGNAL(iconSizeChanged(QSize)), SLOT(setAnimatedLogoSize(QSize))); |
60 | } |
61 | |
62 | void KonqAnimatedLogo::setAnimatedLogoSize(const QSize &size) |
63 | { |
64 | setIconSize(size); |
65 | updateIcons(); |
66 | } |
67 | |
68 | #include "konqanimatedlogo_p.moc" |
69 | |