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 * @brief 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 */
27class KUrlNavigatorButtonBase : public QPushButton
28{
29 Q_OBJECT
30
31public:
32 explicit KUrlNavigatorButtonBase(KUrlNavigator *parent);
33 ~KUrlNavigatorButtonBase() override;
34
35 /**
36 * When having several URL navigator instances, it is important
37 * to provide a visual difference to indicate which URL navigator
38 * is active (usecase: split view in Dolphin). The activation state
39 * is independent from the focus or hover state.
40 * Per default the URL navigator button is marked as active.
41 */
42 void setActive(bool active);
43 bool isActive() const;
44
45protected:
46 enum DisplayHint {
47 EnteredHint = 1,
48 DraggedHint = 2,
49 PopupActiveHint = 4,
50 };
51
52 enum { BorderWidth = 2 };
53
54 void setDisplayHintEnabled(DisplayHint hint, bool enable);
55 bool isDisplayHintEnabled(DisplayHint hint) const;
56
57 void focusInEvent(QFocusEvent *event) override;
58 void focusOutEvent(QFocusEvent *event) override;
59
60 void enterEvent(QEnterEvent *event) override;
61 void leaveEvent(QEvent *event) override;
62
63 void drawHoverBackground(QPainter *painter);
64
65 /** Returns the foreground color by respecting the current display hint. */
66 QColor foregroundColor() const;
67
68private Q_SLOTS:
69 /** Invokes setActive(true). */
70 void activate();
71
72private:
73 bool m_active;
74 int m_displayHint;
75};
76
77} // namespace KDEPrivate
78
79#endif
80

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