Warning, file /plasma/systemsettings/app/sidebar/SidebarMode.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2009 Ben Cooksley <bcooksley@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef SIDEBARMODE_H 0008 #define SIDEBARMODE_H 0009 0010 #include "BaseMode.h" 0011 #include <KSelectionProxyModel> 0012 #include <QIcon> 0013 #include <QWidget> 0014 #include <qqmlregistration.h> 0015 0016 class ModuleView; 0017 class KAboutData; 0018 class QModelIndex; 0019 class QAbstractItemView; 0020 class QAbstractItemModel; 0021 class QAction; 0022 class SidebarMode; 0023 class MenuItem; 0024 0025 class FocusHackWidget : public QWidget 0026 { 0027 Q_OBJECT 0028 public: 0029 explicit FocusHackWidget(QWidget *parent = nullptr); 0030 ~FocusHackWidget() override; 0031 0032 public Q_SLOTS: 0033 void focusNext(); 0034 void focusPrevious(); 0035 }; 0036 0037 class SubcategoryModel : public KSelectionProxyModel 0038 { 0039 Q_OBJECT 0040 Q_PROPERTY(QString title READ title NOTIFY titleChanged) 0041 Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) 0042 Q_PROPERTY(bool categoryOwnedByKCM READ categoryOwnedByKCM NOTIFY categoryOwnedByKCMChanged) 0043 0044 public: 0045 explicit SubcategoryModel(QAbstractItemModel *parentModel, SidebarMode *parent = nullptr); 0046 0047 QString title() const; 0048 QIcon icon() const; 0049 bool categoryOwnedByKCM() const; 0050 0051 void setParentIndex(const QModelIndex &activeModule); 0052 0053 Q_INVOKABLE void loadParentCategoryModule(); 0054 0055 Q_SIGNALS: 0056 void titleChanged(); 0057 void iconChanged(); 0058 void categoryOwnedByKCMChanged(); 0059 0060 private: 0061 QAbstractItemModel *m_parentModel; 0062 SidebarMode *m_sidebarMode; 0063 QPersistentModelIndex m_activeModuleIndex; 0064 }; 0065 0066 class SidebarMode : public BaseMode 0067 { 0068 Q_OBJECT 0069 QML_ELEMENT 0070 QML_UNCREATABLE("Not creatable, use the systemsettings attached property") 0071 0072 Q_PROPERTY(QAbstractItemModel *categoryModel READ categoryModel CONSTANT) 0073 Q_PROPERTY(QAbstractItemModel *searchModel READ searchModel CONSTANT) 0074 Q_PROPERTY(QAbstractItemModel *subCategoryModel READ subCategoryModel CONSTANT) 0075 Q_PROPERTY(int activeCategoryRow READ activeCategoryRow NOTIFY activeCategoryRowChanged) 0076 Q_PROPERTY(int activeSearchRow READ activeSearchRow NOTIFY activeSearchRowChanged) 0077 Q_PROPERTY(int activeSubCategoryRow READ activeSubCategoryRow NOTIFY activeSubCategoryRowChanged) 0078 Q_PROPERTY(int width READ width NOTIFY widthChanged) 0079 Q_PROPERTY(bool actionMenuVisible READ actionMenuVisible NOTIFY actionMenuVisibleChanged) 0080 Q_PROPERTY(bool introPageVisible READ introPageVisible WRITE setIntroPageVisible NOTIFY introPageVisibleChanged) 0081 Q_PROPERTY(bool defaultsIndicatorsVisible READ defaultsIndicatorsVisible NOTIFY defaultsIndicatorsVisibleChanged) 0082 Q_PROPERTY(qreal headerHeight READ headerHeight WRITE setHeaderHeight NOTIFY headerHeightChanged) 0083 0084 public: 0085 SidebarMode(QObject *parent, const QVariantList &args); 0086 ~SidebarMode() override; 0087 QWidget *mainWidget() override; 0088 void initEvent() override; 0089 void giveFocus() override; 0090 ModuleView *moduleView() const override; 0091 void reloadStartupModule() override; 0092 0093 QAbstractItemModel *categoryModel() const; 0094 QAbstractItemModel *searchModel() const; 0095 QAbstractItemModel *subCategoryModel() const; 0096 0097 int activeCategoryRow() const; 0098 int activeSubCategoryRow() const; 0099 int activeSearchRow() const; 0100 0101 int width() const; 0102 0103 bool actionMenuVisible() const; 0104 0105 bool introPageVisible() const; 0106 void setIntroPageVisible(const bool &introPageVisible); 0107 0108 qreal headerHeight() const; 0109 void setHeaderHeight(qreal height); 0110 0111 bool defaultsIndicatorsVisible() const override; 0112 void toggleDefaultsIndicatorsVisibility() override; 0113 0114 Q_INVOKABLE QAction *action(const QString &name) const; 0115 // QML doesn't understand QIcon, otherwise we could get it from the QAction itself 0116 Q_INVOKABLE QString actionIconName(const QString &name) const; 0117 Q_INVOKABLE void showActionMenu(const QPoint &position); 0118 0119 Q_INVOKABLE void loadModule(const QModelIndex &activeModule, const QStringList &args = QStringList()); 0120 0121 /** 0122 * Helper function to move focus to the next/previous QQuickWidget 0123 */ 0124 Q_INVOKABLE void focusNext(); 0125 Q_INVOKABLE void focusPrevious(); 0126 0127 protected: 0128 QList<QAbstractItemView *> views() const override; 0129 bool eventFilter(QObject *watched, QEvent *event) override; 0130 0131 private Q_SLOTS: 0132 void moduleLoaded(); 0133 void updateDefaults(); 0134 void initWidget(); 0135 0136 private: 0137 void initPlaceHolderWidget(); 0138 void updateModelMenuItem(MenuItem *item); 0139 void updateCategoryModel(const QModelIndex &categoryIdx); 0140 void refreshDefaults(); 0141 void setActionMenuVisible(bool visible); 0142 0143 Q_SIGNALS: 0144 void activeCategoryRowChanged(); 0145 void activeSubCategoryRowChanged(); 0146 void activeSearchRowChanged(); 0147 void widthChanged(); 0148 void actionMenuVisibleChanged(); 0149 void introPageVisibleChanged(); 0150 void headerHeightChanged(); 0151 void defaultsIndicatorsVisibleChanged(); 0152 0153 private: 0154 class Private; 0155 Private *const d; 0156 }; 0157 0158 #endif