1/*
2 SPDX-FileCopyrightText: 2006-2010 Peter Penz <peter.penz@gmx.at>
3 SPDX-FileCopyrightText: 2006 Aaron J. Seigo <aseigo@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KURLNAVIGATORBUTTONBASE_P_H
9#define KURLNAVIGATORBUTTONBASE_P_H
10
11#include <QColor>
12#include <QPushButton>
13
14class QUrl;
15class QEvent;
16
17class KUrlNavigator;
18
19namespace KDEPrivate
20{
21/*!
22 * Base class for buttons of the URL navigator.
23 *
24 * Buttons of the URL navigator offer an active/inactive
25 * state and custom display hints.
26 *
27 * \internal
28 */
29class KUrlNavigatorButtonBase : public QPushButton
30{
31 Q_OBJECT
32
33public:
34 explicit KUrlNavigatorButtonBase(KUrlNavigator *parent);
35 ~KUrlNavigatorButtonBase() override;
36
37 /*!
38 * When having several URL navigator instances, it is important
39 * to provide a visual difference to indicate which URL navigator
40 * is active (usecase: split view in Dolphin). The activation state
41 * is independent from the focus or hover state.
42 * Per default the URL navigator button is marked as active.
43 */
44 void setActive(bool active);
45 bool isActive() const;
46
47protected:
48 enum DisplayHint {
49 EnteredHint = 1,
50 DraggedHint = 2,
51 PopupActiveHint = 4,
52 };
53
54 enum {
55 BorderWidth = 2
56 };
57
58 void setDisplayHintEnabled(DisplayHint hint, bool enable);
59 bool isDisplayHintEnabled(DisplayHint hint) const;
60
61 void focusInEvent(QFocusEvent *event) override;
62 void focusOutEvent(QFocusEvent *event) override;
63
64 void enterEvent(QEnterEvent *event) override;
65 void leaveEvent(QEvent *event) override;
66
67 void drawHoverBackground(QPainter *painter);
68
69 /*! Returns the foreground color by respecting the current display hint. */
70 QColor foregroundColor() const;
71
72private Q_SLOTS:
73 /*! Invokes setActive(true). */
74 void activate();
75
76private:
77 bool m_active;
78 int m_displayHint;
79};
80
81} // namespace KDEPrivate
82
83#endif
84

source code of kio/src/filewidgets/kurlnavigatorbuttonbase_p.h