File indexing completed on 2024-05-05 17:33:20
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "discovercommon_export.h" 0010 #include <QObject> 0011 0012 /** 0013 * An action class that doesn't need QtWidgets 0014 */ 0015 class DISCOVERCOMMON_EXPORT DiscoverAction : public QObject 0016 { 0017 Q_OBJECT 0018 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) 0019 Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip NOTIFY toolTipChanged) 0020 Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged) 0021 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) 0022 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) 0023 public: 0024 DiscoverAction(QObject *parent = nullptr); 0025 DiscoverAction(const QString &text, QObject *parent = nullptr); 0026 DiscoverAction(const QString &icon, const QString &text, QObject *parent = nullptr); 0027 0028 void setText(const QString &text); 0029 void setToolTip(const QString &toolTip); 0030 void setIconName(const QString &iconName); 0031 void setEnabled(bool enabled); 0032 void setVisible(bool enabled); 0033 0034 bool isVisible() const 0035 { 0036 return m_isVisible; 0037 } 0038 0039 bool isEnabled() const 0040 { 0041 return m_isEnabled; 0042 } 0043 0044 QString text() const 0045 { 0046 return m_text; 0047 } 0048 0049 QString toolTip() const 0050 { 0051 return m_toolTip; 0052 } 0053 0054 QString iconName() const 0055 { 0056 return m_icon; 0057 } 0058 0059 public Q_SLOTS: 0060 void trigger(); 0061 0062 Q_SIGNALS: 0063 void triggered(); 0064 0065 void textChanged(const QString &text); 0066 void toolTipChanged(const QString &toolTip); 0067 void iconNameChanged(const QString &iconName); 0068 void visibleChanged(bool isVisible); 0069 void enabledChanged(bool isEnabled); 0070 0071 private: 0072 bool m_isVisible = true; 0073 bool m_isEnabled = true; 0074 QString m_text; 0075 QString m_toolTip; 0076 QString m_icon; 0077 };