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

0001 /* This file is part of the KDE project
0002    Copyright (C) 2011-2018 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 KEXILINKWIDGET_H
0021 #define KEXILINKWIDGET_H
0022 
0023 #include "kexiutils_export.h"
0024 
0025 #include <QLabel>
0026 
0027 class QKeySequence;
0028 
0029 //! Link widget
0030 class KEXIUTILS_EXPORT KexiLinkWidget : public QLabel
0031 {
0032     Q_OBJECT
0033     Q_PROPERTY(QString link READ link WRITE setLink)
0034     Q_PROPERTY(QString linkText READ linkText WRITE setLinkText)
0035     Q_PROPERTY(QString format READ format WRITE setFormat)
0036 public:
0037     explicit KexiLinkWidget(QWidget* parent = 0);
0038 
0039     KexiLinkWidget(const QString& link, const QString& linkText, QWidget* parent = 0);
0040 
0041     virtual ~KexiLinkWidget();
0042 
0043     QString link() const;
0044 
0045     QString linkText() const;
0046 
0047     QString format() const;
0048 
0049     QKeySequence shortcut() const;
0050 
0051 public Q_SLOTS:
0052     void setLink(const QString& link);
0053 
0054     void setLinkText(const QString& linkText);
0055 
0056     //! Sets format for the button.
0057     /*! Format defines user-visible text written around the link.
0058         Use "%L" as a placeholder for the link, e.g. when format
0059         is "‹ %L" and link text is "Back", the widget will show "‹ Back"
0060         where "Back" is a link. By default format is empty, what means
0061         only the link is displayed. */
0062     void setFormat(const QString& format);
0063 
0064     void click();
0065 
0066     void setShortcut(const QKeySequence &key);
0067 
0068 protected:
0069     virtual void changeEvent(QEvent* event) override;
0070 
0071 private:
0072     QString text() const { return QLabel::text(); }
0073     void setText(const QString& text) { QLabel::setText(text); }
0074 
0075     class Private;
0076     Private * const d;
0077 };
0078 
0079 #endif