File indexing completed on 2024-05-05 04:49:25
0001 /**************************************************************************************** 0002 * Copyright (c) 2006 Peter Penz <peter.penz@gmx.at> * 0003 * Copyright (c) 2006 Aaron Seigo <aseigo@kde.org> * 0004 * Copyright (c) 2009 Seb Ruiz <ruiz@kde.org> * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify it under * 0007 * the terms of the GNU General Public License as published by the Free Software * 0008 * Foundation; either version 2 of the License, or (at your option) any later * 0009 * version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0013 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License along with * 0016 * this program. If not, see <http://www.gnu.org/licenses/>. * 0017 ****************************************************************************************/ 0018 0019 #ifndef BREADCRUMBITEMBUTTON_P_H 0020 #define BREADCRUMBITEMBUTTON_P_H 0021 0022 #include <QColor> 0023 0024 #include "widgets/ElidingButton.h" 0025 0026 class QEvent; 0027 0028 /** 0029 * @brief Base class for buttons of the URL navigator. 0030 * 0031 * Each button of the URL navigator contains an URL, which 0032 * is set as soon as the button has been clicked. 0033 */ 0034 class BreadcrumbItemButton : public Amarok::ElidingButton 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 explicit BreadcrumbItemButton( QWidget* parent ); 0040 BreadcrumbItemButton( const QString &text, QWidget *parent ); 0041 BreadcrumbItemButton( const QIcon &icon, const QString &text, QWidget *parent ); 0042 ~BreadcrumbItemButton() override; 0043 0044 void setActive( const bool active ); 0045 0046 QSize sizeHint() const override; 0047 0048 protected: 0049 enum DisplayHint 0050 { 0051 ActiveHint = 1, 0052 HoverHint = 2 0053 }; 0054 0055 void setDisplayHintEnabled(DisplayHint hint, bool enable); 0056 bool isDisplayHintEnabled(DisplayHint hint) const; 0057 0058 void enterEvent(QEvent* event) override; 0059 void leaveEvent(QEvent* event) override; 0060 0061 void paintEvent(QPaintEvent* event) override; 0062 virtual void drawHoverBackground(QPainter* painter); 0063 0064 /** Returns the foreground color by respecting the current display hint. */ 0065 QColor foregroundColor() const; 0066 0067 private: 0068 void init(); 0069 int m_displayHint; 0070 }; 0071 0072 class BreadcrumbItemMenuButton : public BreadcrumbItemButton 0073 { 0074 Q_OBJECT 0075 0076 public: 0077 explicit BreadcrumbItemMenuButton( QWidget* parent ); 0078 ~BreadcrumbItemMenuButton() override { } 0079 0080 protected: 0081 void paintEvent(QPaintEvent* event) override; 0082 }; 0083 0084 class BreadcrumbUrlMenuButton : public BreadcrumbItemButton 0085 { 0086 Q_OBJECT 0087 public: 0088 BreadcrumbUrlMenuButton( const QString &urlsCommand, QWidget *parent ); 0089 ~BreadcrumbUrlMenuButton() override; 0090 0091 public Q_SLOTS: 0092 void generateMenu( const QPoint &pos ); 0093 0094 protected Q_SLOTS: 0095 void showMenu(); 0096 void copyCurrentToClipboard(); 0097 0098 0099 private: 0100 QString m_urlsCommand; 0101 QAction * m_copyToClipboardAction; 0102 0103 }; 0104 0105 #endif