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

0001 /* This file is part of the KDE project
0002    Copyright (C) 2005-2007 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 KEXISMALLTOOLBUTTON_H
0021 #define KEXISMALLTOOLBUTTON_H
0022 
0023 #include <QToolButton>
0024 #include "kexiutils_export.h"
0025 
0026 class QAction;
0027 class QIcon;
0028 
0029 //! @short A small tool button with icon and optional text
0030 class KEXIUTILS_EXPORT KexiSmallToolButton : public QToolButton
0031 {
0032     Q_OBJECT
0033 public:
0034     explicit KexiSmallToolButton(QWidget* parent = 0);
0035 
0036     explicit KexiSmallToolButton(const QString& text, QWidget* parent = 0);
0037 
0038     KexiSmallToolButton(const QIcon& icon, const QString& text, QWidget* parent = 0);
0039 
0040     explicit KexiSmallToolButton(const QIcon& icon, QWidget* parent = 0);
0041 
0042     explicit KexiSmallToolButton(QAction *action, QWidget* parent = 0);
0043 
0044     virtual ~KexiSmallToolButton();
0045 
0046     void updateAction();
0047 
0048     virtual void setIcon(const QIcon& icon);
0049     virtual void setIcon(const QString &iconName);
0050     virtual void setText(const QString& text);
0051     void setToolButtonStyle(Qt::ToolButtonStyle style);
0052     virtual QSize sizeHint() const override;
0053     QAction* action() const;
0054 
0055 protected Q_SLOTS:
0056     void slotActionChanged();
0057     void slotButtonToggled(bool checked);
0058     void slotActionToggled(bool checked);
0059 
0060 protected:
0061     void update(const QString& text, const QIcon& icon, bool tipToo = false);
0062     void init();
0063 
0064     class Private;
0065     Private * const d;
0066 };
0067 
0068 class QStyleOption;
0069 
0070 //! @short separator for custom toolbars
0071 class KEXIUTILS_EXPORT KexiToolBarSeparator : public QWidget
0072 {
0073     Q_OBJECT
0074 public:
0075     explicit KexiToolBarSeparator(QWidget *parent);
0076     virtual ~KexiToolBarSeparator();
0077 
0078     QSize sizeHint() const override;
0079     Qt::Orientation orientation() const;
0080 public Q_SLOTS:
0081     void setOrientation(Qt::Orientation o);
0082 protected:
0083     virtual void paintEvent(QPaintEvent *e) override;
0084     void initStyleOption(QStyleOption *o) const;
0085 
0086 private:
0087     class Private;
0088 
0089     Private* const d;
0090 };
0091 
0092 #endif