File indexing completed on 2024-05-12 16:39:37
0001 /* This file is part of the KDE libraries 0002 Copyright (C) 2007 Aurélien Gâteau <agateau@kde.org> 0003 Copyright (C) 2012 Jean-Nicolas Artaud <jeannicolasartaud@gmail.com> 0004 Copyright (C) 2012-2016 Jarosław Staniek <staniek@kde.org> 0005 0006 Based on Calligra libs' KoGroupButton 0007 0008 This library is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU Library General Public 0010 License version 2 as published by the Free Software Foundation. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #ifndef KEXIGROUPBUTTON_H 0024 #define KEXIGROUPBUTTON_H 0025 0026 #include "kexicore_export.h" 0027 0028 // Qt 0029 #include <QToolButton> 0030 0031 /** 0032 * A thin tool button which can be visually grouped with other buttons. 0033 * 0034 * The group can thus look like one solid bar: ( button1 | button2 | button3 ) 0035 * 0036 * For groupping layout can be used. For exclusive checkable behaviour assign QButtonGroup on the buttons. 0037 */ 0038 class KEXICORE_EXPORT KexiGroupButton : public QToolButton 0039 { 0040 Q_OBJECT 0041 Q_PROPERTY( GroupPosition groupPosition READ groupPosition WRITE setGroupPosition ) 0042 public: 0043 /** 0044 * Position of the button within the button group what affects the appearance. 0045 */ 0046 enum GroupPosition { 0047 NoGroup, //!< No particular position, gives the button unchanged appearance 0048 GroupLeft, //!< The button is at the left of the group, so it would have rounded the left part 0049 GroupRight, //!< The button is at the right of the group, so it would have rounded the right part 0050 GroupCenter //!< The button is on the center of the group, so it would have separators on both sides 0051 }; 0052 Q_ENUM(GroupPosition) 0053 0054 explicit KexiGroupButton(GroupPosition position, QWidget* parent = 0); 0055 0056 /** 0057 * Creates button with no NoGroup position. 0058 */ 0059 explicit KexiGroupButton(QWidget* parent = 0); 0060 0061 virtual ~KexiGroupButton(); 0062 0063 void setGroupPosition(KexiGroupButton::GroupPosition groupPosition); 0064 0065 KexiGroupButton::GroupPosition groupPosition() const; 0066 0067 protected: 0068 virtual void paintEvent(QPaintEvent* event) override; 0069 void mousePressEvent(QMouseEvent *e) override; 0070 0071 private: 0072 class Private; 0073 Private *const d; 0074 }; 0075 0076 #endif /* KEXIGROUPBUTTON_H */