File indexing completed on 2024-05-12 16:39:56

0001 /* This file is part of the KDE project
0002    Copyright (C) 2012 Jarosław Staniek <staniek@kde.org>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this program; see the file COPYING.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef KEXILINKBUTTON_H
0021 #define KEXILINKBUTTON_H
0022 
0023 #include "kexiutils_export.h"
0024 
0025 #include <QPushButton>
0026 
0027 class KGuiItem;
0028 
0029 //! A flat icon-based button without background that behaves like a link
0030 class KEXIUTILS_EXPORT KexiLinkButton : public QPushButton
0031 {
0032     Q_OBJECT
0033 public:
0034     explicit KexiLinkButton(QWidget* parent = 0);
0035 
0036     explicit KexiLinkButton(const QIcon &icon, QWidget* parent = 0);
0037 
0038     explicit KexiLinkButton(const KGuiItem &item, QWidget *parent = 0);
0039 
0040     explicit KexiLinkButton(const QPixmap &pixmap, QWidget* parent = 0);
0041 
0042     virtual ~KexiLinkButton();
0043 
0044     /*! If true, foreground color of the current palette is always used for painting
0045         the button's icon. This is done by replacing color.
0046         The foreground color is QPalette::Text by default, and can be changed
0047         using setForegroundRole().
0048         The icon is expected to be monochrome.
0049         Works well also after palette change.
0050         False by default. */
0051     void setUsesForegroundColor(bool set);
0052 
0053     /*! @return true if foreground color of the current palette is always used for painting
0054         the button's icon. */
0055     bool usesForegroundColor() const;
0056 
0057     void setIcon(const QIcon &icon);
0058 
0059 protected:
0060     virtual void changeEvent(QEvent* event) override;
0061 
0062 private:
0063     void init();
0064     void updateIcon(const QIcon &icon);
0065 
0066     class Private;
0067     Private * const d;
0068 };
0069 
0070 #endif