]> cloud.milkyroute.net Git - dolphin.git/blob - src/urlbutton.cpp
Make use of KFilePlaces instead of the bookmark system in the URL
[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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include "urlnavigatorbutton.h"
22 #include "urlnavigator.h"
23
24 UrlButton::UrlButton(UrlNavigator* parent) :
25 QPushButton(parent),
26 m_displayHint(0),
27 m_urlNavigator(parent)
28 {
29 setFocusPolicy(Qt::NoFocus);
30 setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
31 setMinimumHeight(parent->minimumHeight());
32
33 connect(this, SIGNAL(clicked()), parent, SLOT(requestActivation()));
34 }
35
36 UrlButton::~UrlButton()
37 {
38 }
39
40 void UrlButton::setDisplayHintEnabled(DisplayHint hint,
41 bool enable)
42 {
43 if (enable) {
44 m_displayHint = m_displayHint | hint;
45 }
46 else {
47 m_displayHint = m_displayHint & ~hint;
48 }
49 update();
50 }
51
52 bool UrlButton::isDisplayHintEnabled(DisplayHint hint) const
53 {
54 return (m_displayHint & hint) > 0;
55 }
56
57 void UrlButton::enterEvent(QEvent* event)
58 {
59 QPushButton::enterEvent(event);
60 setDisplayHintEnabled(EnteredHint, true);
61 update();
62 }
63
64 void UrlButton::leaveEvent(QEvent* event)
65 {
66 QPushButton::leaveEvent(event);
67 setDisplayHintEnabled(EnteredHint, false);
68 update();
69 }
70
71 QColor UrlButton::mixColors(const QColor& c1,
72 const QColor& c2) const
73 {
74 const int red = (c1.red() + c2.red()) / 2;
75 const int green = (c1.green() + c2.green()) / 2;
76 const int blue = (c1.blue() + c2.blue()) / 2;
77 return QColor(red, green, blue);
78 }
79
80 #include "urlbutton.moc"