File indexing completed on 2024-05-05 04:46:53

0001 /*
0002  * <one line to give the program's name and a brief idea of what it does.>
0003  * Copyright (C) 2019  camilo <chiguitar@unal.edu.co>
0004  *
0005  * This program is free software: you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation, either version 3 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #pragma once
0020 
0021 #include <QObject>
0022 #include <QQmlEngine>
0023 
0024 /**
0025  * @brief The TabViewInfo class.
0026  * Groups the attached properties used for setting the data information for the TabView children views.
0027  * @see TabView
0028  * @see TabViewItem
0029  * 
0030  * @code
0031  * Item
0032  * {
0033  *  Maui.TabVieInfo.tabTitle: "Tab1"
0034  *  Maui.TabViewInfo.tabIcon: "folder"
0035  * }
0036  * @endcode
0037  */
0038 class TabViewInfo : public QObject
0039 {
0040     Q_OBJECT
0041     QML_ELEMENT
0042     QML_ATTACHED(AppView)
0043     QML_UNCREATABLE("Cannot be created Controls")
0044     /**
0045      * The title for the tab view. Used in the tab button.
0046      */
0047     Q_PROPERTY(QString tabTitle READ tabTitle WRITE setTabTitle NOTIFY tabTitleChanged)
0048     
0049     /**
0050      * The text to be shown in the tool-tip when hovering over the tab button representing the view.
0051      */
0052     Q_PROPERTY(QString tabToolTipText READ tabToolTipText WRITE setTabToolTipText NOTIFY tabToolTipTextChanged)
0053     
0054     /**
0055      * The color to be used as an indicator in the tab button representing the view.
0056      */
0057     Q_PROPERTY(QString tabColor READ tabColor WRITE setTabColor NOTIFY tabColorChanged)
0058     
0059     /**
0060      * The icon to be used in the tab button representing the view.
0061      */
0062     Q_PROPERTY(QString tabIcon READ tabIcon WRITE setTabIcon NOTIFY tabIconChanged)
0063         
0064 public:
0065     static TabViewInfo *qmlAttachedProperties(QObject *object)
0066     {
0067         Q_UNUSED(object)
0068         
0069         return new TabViewInfo(object);
0070     }
0071     
0072     inline void setTabTitle(const QString &value)
0073     {
0074         if (value == m_tabTitle)
0075             return;
0076         
0077         m_tabTitle = value;
0078         Q_EMIT tabTitleChanged();
0079     }
0080     
0081     inline void setTabToolTipText(const QString &value)
0082     {
0083         if (value == m_tabToolTipText)
0084             return;
0085         
0086         m_tabToolTipText = value;
0087         Q_EMIT tabToolTipTextChanged();
0088     }
0089     
0090     inline void setTabColor(const QString &value)
0091     {
0092         if (value == m_tabColor)
0093             return;
0094         
0095         m_tabColor = value;
0096         Q_EMIT tabColorChanged();
0097     }    
0098     
0099     inline void setTabIcon(const QString &value)
0100     {
0101         if (value == m_tabIcon)
0102             return;
0103         
0104         m_tabIcon = value;
0105         Q_EMIT tabIconChanged();
0106     }
0107     
0108     inline const QString tabTitle() const
0109     {
0110         return m_tabTitle;
0111     }
0112     
0113     inline const QString tabToolTipText() const
0114     {
0115         return m_tabToolTipText;
0116     }
0117     
0118     inline const QString tabColor() const
0119     {
0120         return m_tabColor;
0121     }
0122     
0123     inline const QString tabIcon() const
0124     {
0125         return m_tabIcon;
0126     }
0127     
0128 private:
0129     using QObject::QObject;
0130     
0131     QString m_tabTitle;
0132     QString m_tabToolTipText;
0133     QString m_tabIcon;
0134     QString m_tabColor;
0135     
0136 Q_SIGNALS:
0137     void tabTitleChanged();
0138     void tabToolTipTextChanged();
0139     void tabColorChanged();
0140     void tabIconChanged();
0141 };
0142 
0143 QML_DECLARE_TYPEINFO(TabViewInfo, QML_HAS_ATTACHED_PROPERTIES)
0144