]>
cloud.milkyroute.net Git - dolphin.git/blob - 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>) *
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. *
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. *
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 ***************************************************************************/
21 #include "urlnavigatorbutton.h"
25 #include <qfontmetrics.h>
29 #include <kpopupmenu.h>
30 #include <kiconloader.h>
33 #include "urlnavigator.h"
37 URLButton::URLButton(URLNavigator
* parent
)
38 : QPushButton(parent
),
40 m_urlNavigator(parent
)
42 setFocusPolicy(Qt::NoFocus
);
43 setSizePolicy(QSizePolicy::Maximum
, QSizePolicy::Fixed
);
44 setMinimumHeight(parent
->minimumHeight());
46 connect(this, SIGNAL(clicked()), parent
, SLOT(slotRequestActivation()));
47 connect(&Dolphin::mainWin(), SIGNAL(activeViewChanged()),
48 this, SLOT(update()));
51 URLButton::~URLButton()
55 URLNavigator
* URLButton::urlNavigator() const
57 return m_urlNavigator
;
60 void URLButton::setDisplayHintEnabled(DisplayHint hint
,
64 m_displayHint
= m_displayHint
| hint
;
67 m_displayHint
= m_displayHint
& ~hint
;
72 bool URLButton::isDisplayHintEnabled(DisplayHint hint
) const
74 return (m_displayHint
& hint
) > 0;
77 void URLButton::enterEvent(QEvent
* event
)
79 QPushButton::enterEvent(event
);
80 setDisplayHintEnabled(EnteredHint
, true);
84 void URLButton::leaveEvent(QEvent
* event
)
86 QPushButton::leaveEvent(event
);
87 setDisplayHintEnabled(EnteredHint
, false);
91 QColor
URLButton::mixColors(const QColor
& c1
,
92 const QColor
& c2
) const
94 const int Qt::red
= (c1
.Qt::red() + c2
.Qt::red()) / 2;
95 const int Qt::green
= (c1
.Qt::green() + c2
.Qt::green()) / 2;
96 const int Qt::blue
= (c1
.Qt::blue() + c2
.Qt::blue()) / 2;
97 return QColor(Qt::red
, Qt::green
, Qt::blue
);