File indexing completed on 2024-05-12 16:39:56
0001 /* This file is part of the KDE project 0002 Copyright (C) 2013 Oleg Kukharchuk <oleg.kuh@gmail.com> 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 KEXIPUSHBUTTON_H 0021 #define KEXIPUSHBUTTON_H 0022 0023 #include <kexiutils/kexiutils_export.h> 0024 0025 #include <QPushButton> 0026 #include <kexiutils/utils.h> 0027 0028 /*! 0029 * \short A PushButton widget with hyperlinks support 0030 */ 0031 class KEXIUTILS_EXPORT KexiPushButton : public QPushButton 0032 { 0033 Q_OBJECT 0034 0035 Q_PROPERTY(QString hyperlink READ hyperlink WRITE setHyperlink) 0036 Q_PROPERTY(HyperlinkType hyperlinkType READ hyperlinkType WRITE setHyperlinkType) 0037 Q_PROPERTY(KexiUtils::OpenHyperlinkOptions::HyperlinkTool hyperlinkTool READ hyperlinkTool WRITE setHyperlinkTool) 0038 Q_PROPERTY(bool hyperlinkExecutable READ isHyperlinkExecutable WRITE setHyperlinkExecutable) 0039 Q_PROPERTY(bool remoteHyperlink READ isRemoteHyperlink WRITE setRemoteHyperlink) 0040 public: 0041 0042 /*! 0043 * Type of the Hyperlink 0044 */ 0045 enum HyperlinkType { 0046 NoHyperlink, /*!< Hyperlinks are not supported */ 0047 StaticHyperlink, /*!< Static hyperlink provided by \a hyperlink property*/ 0048 DynamicHyperlink /*!< Dynamic hyperlink (used in data-aware widgets) */ 0049 }; 0050 Q_ENUM(HyperlinkType) 0051 0052 //! Default constructor 0053 explicit KexiPushButton(QWidget *parent = 0); 0054 0055 //! Constructor, that sets the button-text to text 0056 explicit KexiPushButton(const QString &text, QWidget *parent = 0); 0057 ~KexiPushButton(); 0058 0059 /*! \property KexiPushButton::hyperlink 0060 * Sets hyperlink for the button 0061 */ 0062 void setHyperlink(const QString &url); 0063 QString hyperlink() const; 0064 0065 /*! \property KexiPushButton::hyperlinkType 0066 * Sets the hyperlink type to 0067 * The valid vaues are descibed by the KexiPushButton::HyperlinkType enum 0068 * 0069 * The default value is NoHyperlink 0070 */ 0071 void setHyperlinkType(HyperlinkType type); 0072 HyperlinkType hyperlinkType() const; 0073 0074 /*! \property KexiPushButton::hyperlinkTool 0075 * Sets the tool for opening hyperlinks 0076 * The valid values are described by the KexiUtils::OpenHyperlinkOptions::HyperlinkTool enum 0077 * 0078 * The default value is DefaultHyperlinkTool 0079 */ 0080 void setHyperlinkTool(KexiUtils::OpenHyperlinkOptions::HyperlinkTool tool); 0081 KexiUtils::OpenHyperlinkOptions::HyperlinkTool hyperlinkTool() const; 0082 0083 /*! \property KexiPushButton::hyperlinkExecutable 0084 * If true hyperlink can be an executable file 0085 * 0086 * The default value is false 0087 */ 0088 void setHyperlinkExecutable(bool exec); 0089 bool isHyperlinkExecutable() const; 0090 0091 /*! \property KexiPushButton::hyperlinkLocal 0092 * If \a true only local hyperlink are allowed 0093 * 0094 * The default value is true 0095 */ 0096 void setRemoteHyperlink(bool remote); 0097 bool isRemoteHyperlink() const; 0098 0099 protected Q_SLOTS: 0100 void slotClicked(); 0101 0102 protected: 0103 void setLocalBasePath(const QString &basePath); 0104 0105 private: 0106 class Private; 0107 friend class Private; 0108 Private * const d; 0109 }; 0110 #endif // KEXIPUSHBUTTON_H