]> cloud.milkyroute.net Git - dolphin.git/blob - src/urlbutton.cpp
minor cosmetic update of the progress indication
[dolphin.git] / src / urlbutton.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
3 * Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>) *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #include "urlnavigatorbutton.h"
22 #include <kurl.h>
23 #include <qtooltip.h>
24 #include <qcursor.h>
25 #include <qfontmetrics.h>
26 //Added by qt3to4:
27 #include <QEvent>
28 #include <kiconloader.h>
29 #include <klocale.h>
30
31 #include "urlnavigator.h"
32 #include "dolphinmainwindow.h"
33
34
35 UrlButton::UrlButton(UrlNavigator* parent)
36 : QPushButton(parent),
37 m_displayHint(0),
38 m_urlNavigator(parent)
39 {
40 setFocusPolicy(Qt::NoFocus);
41 setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
42 setMinimumHeight(parent->minimumHeight());
43
44 connect(this, SIGNAL(clicked()), parent, SLOT(slotRequestActivation()));
45 connect(parent->dolphinView()->mainWindow(), SIGNAL(activeViewChanged()),
46 this, SLOT(update()));
47 }
48
49 UrlButton::~UrlButton()
50 {
51 }
52
53 UrlNavigator* UrlButton::urlNavigator() const
54 {
55 return m_urlNavigator;
56 }
57
58 void UrlButton::setDisplayHintEnabled(DisplayHint hint,
59 bool enable)
60 {
61 if (enable) {
62 m_displayHint = m_displayHint | hint;
63 }
64 else {
65 m_displayHint = m_displayHint & ~hint;
66 }
67 update();
68 }
69
70 bool UrlButton::isDisplayHintEnabled(DisplayHint hint) const
71 {
72 return (m_displayHint & hint) > 0;
73 }
74
75 void UrlButton::enterEvent(QEvent* event)
76 {
77 QPushButton::enterEvent(event);
78 setDisplayHintEnabled(EnteredHint, true);
79 update();
80 }
81
82 void UrlButton::leaveEvent(QEvent* event)
83 {
84 QPushButton::leaveEvent(event);
85 setDisplayHintEnabled(EnteredHint, false);
86 update();
87 }
88
89 QColor UrlButton::mixColors(const QColor& c1,
90 const QColor& c2) const
91 {
92 const int red = (c1.red() + c2.red()) / 2;
93 const int green = (c1.green() + c2.green()) / 2;
94 const int blue = (c1.blue() + c2.blue()) / 2;
95 return QColor(red, green, blue);
96 }
97
98 #include "urlbutton.moc"