| 1 | // Copyright (C) 2024 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKSIDEBAR_P_P_H |
| 5 | #define QQUICKSIDEBAR_P_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtQuickTemplates2/private/qquickcontainer_p_p.h> |
| 19 | #include <QtCore/qstandardpaths.h> |
| 20 | #include <QtQuickTemplates2/private/qquickmenu_p.h> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | class QQuickContextMenu; |
| 25 | |
| 26 | class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickSideBarPrivate : public QQuickContainerPrivate |
| 27 | { |
| 28 | public: |
| 29 | Q_DECLARE_PUBLIC(QQuickSideBar) |
| 30 | |
| 31 | static QQuickSideBarPrivate *get(QQuickSideBar *sidebar) |
| 32 | { |
| 33 | return sidebar->d_func(); |
| 34 | } |
| 35 | |
| 36 | QQuickItem *createDelegateItem(QQmlComponent *component, const QVariantMap &initialProperties); |
| 37 | void repopulate(); |
| 38 | void buttonClicked(); |
| 39 | |
| 40 | QUrl dialogFolder() const; |
| 41 | void setDialogFolder(const QUrl &folder); |
| 42 | QString displayNameFromFolderPath(const QString &filePath); |
| 43 | QUrl folderIconSource() const; |
| 44 | QUrl folderIconSource(QStandardPaths::StandardLocation stdLocation) const; |
| 45 | QSize dialogIconSize() const; |
| 46 | void folderChanged(); |
| 47 | |
| 48 | void readSettings(); |
| 49 | void writeSettings() const; |
| 50 | |
| 51 | void addFavorite(const QUrl &favorite); |
| 52 | void removeFavorite(const QUrl &favorite); |
| 53 | bool showAddFavoriteDelegate() const; |
| 54 | void setShowAddFavoriteDelegate(bool show); |
| 55 | bool addFavoriteDelegateHovered() const; |
| 56 | void setAddFavoriteDelegateHovered(bool hovered); |
| 57 | QUrl addFavoriteIconUrl() const; |
| 58 | |
| 59 | void initContextMenu(); |
| 60 | void handleContextMenuRequested(QPointF pos); |
| 61 | void handleRemoveAction(); |
| 62 | |
| 63 | protected: |
| 64 | qreal getContentWidth() const override; |
| 65 | qreal getContentHeight() const override; |
| 66 | void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override; |
| 67 | void itemImplicitWidthChanged(QQuickItem *item) override; |
| 68 | void itemImplicitHeightChanged(QQuickItem *item) override; |
| 69 | |
| 70 | |
| 71 | private: |
| 72 | QQuickDialog *dialog = nullptr; |
| 73 | QQmlComponent *buttonDelegate = nullptr; |
| 74 | QQmlComponent *separatorDelegate = nullptr; |
| 75 | QQmlComponent *addFavoriteDelegate = nullptr; |
| 76 | QQuickContextMenu *contextMenu = nullptr; |
| 77 | QQuickMenu *menu = nullptr; |
| 78 | QQuickAction *removeAction = nullptr; |
| 79 | QUrl urlToBeRemoved; |
| 80 | QList<QStandardPaths::StandardLocation> folderPaths; |
| 81 | QList<QUrl> favoritePaths; |
| 82 | QUrl currentButtonClickedUrl; |
| 83 | qreal addFavoriteButtonImplicitSize = 0; |
| 84 | qreal separatorImplicitSize = 0; |
| 85 | bool folderPathsValid = false; |
| 86 | bool favoritePathsValid = false; |
| 87 | bool repopulating = false; |
| 88 | bool addFavoriteDelegateVisible = false; |
| 89 | bool addFavoriteHovered = false; |
| 90 | bool showSeparator = false; |
| 91 | }; |
| 92 | |
| 93 | QT_END_NAMESPACE |
| 94 | |
| 95 | #endif // QQUICKSIDEBAR_P_P_H |
| 96 |
