File indexing completed on 2024-04-21 05:31:18

0001 /*
0002     SPDX-FileCopyrightText: 2018 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef MENU_H
0007 #define MENU_H
0008 
0009 // Qt
0010 #include <QObject>
0011 
0012 // Plasma
0013 #include <Plasma/ContainmentActions>
0014 
0015 class QAction;
0016 class QMenu;
0017 
0018 enum ViewType
0019 {
0020     DockView = 0,
0021     PanelView
0022 };
0023 
0024 struct LayoutInfo {
0025     QString layoutName;
0026     bool isBackgroundFileIcon;
0027     QString iconName;
0028 };
0029 
0030 struct ViewTypeData {
0031     ViewType type{ViewType::DockView};
0032     bool isCloned{true};
0033     int clonesCount{0};
0034 };
0035 
0036 class Menu : public Plasma::ContainmentActions
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     Menu(QObject *parent, const QVariantList &args);
0042     ~Menu() override;
0043 
0044     QList<QAction *> contextualActions() override;
0045     void restore(const KConfigGroup &) override;
0046 
0047     QAction *action(const QString &name);
0048 private Q_SLOTS:
0049     void populateLayouts();
0050     void populateMoveToLayouts();
0051     void populateViewTemplates();
0052     void quitApplication();
0053     void requestConfiguration();
0054     void requestWidgetExplorer();
0055     void updateViewData();
0056     void updateVisibleActions();
0057 
0058     void addView(QAction *action);
0059     void moveToLayout(QAction *action);
0060     void switchToLayout(QAction *action);
0061 
0062 private:
0063     QStringList m_data;
0064     QStringList m_viewTemplates;
0065 
0066     QStringList m_actionsAlwaysShown;
0067     QStringList m_activeLayoutNames;
0068 
0069     ViewTypeData m_view;
0070 
0071     QHash<QString, QAction *> m_actions;
0072 
0073     QMenu *m_addViewMenu{nullptr};
0074     QMenu *m_switchLayoutsMenu{nullptr};
0075     QMenu *m_moveToLayoutMenu{nullptr};
0076 };
0077 
0078 #endif