File indexing completed on 2024-04-14 15:37:20

0001 /*
0002 *  Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
0003 *
0004 *  This file is part of Latte-Dock
0005 *
0006 *  Latte-Dock is free software; you can redistribute it and/or
0007 *  modify it under the terms of the GNU General Public License as
0008 *  published by the Free Software Foundation; either version 2 of
0009 *  the License, or (at your option) any later version.
0010 *
0011 *  Latte-Dock is distributed in the hope that it will be useful,
0012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 *  GNU General Public License for more details.
0015 *
0016 *  You should have received a copy of the GNU General Public License
0017 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 #ifndef CONTEXTMENU_H
0021 #define CONTEXTMENU_H
0022 
0023 // Qt
0024 #include <QEvent>
0025 #include <QMenu>
0026 #include <QMetaMethod>
0027 #include <QQuickItem>
0028 #include <QMouseEvent>
0029 #include <QObject>
0030 
0031 namespace Plasma {
0032 class Applet;
0033 class Containment;
0034 }
0035 
0036 namespace Latte {
0037 class View;
0038 }
0039 
0040 namespace Latte {
0041 namespace ViewPart {
0042 
0043 class ContextMenu : public QObject
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048     ContextMenu(Latte::View *view);
0049     ~ContextMenu() override;
0050 
0051     QMenu *menu();
0052 
0053     bool mousePressEvent(QMouseEvent *event);
0054 
0055 signals:
0056     void menuChanged();
0057 
0058 private slots:
0059     void menuAboutToHide();
0060 
0061 private:
0062     void addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event);
0063     void addContainmentActions(QMenu *desktopMenu, QEvent *event);
0064     void updateAppletContainsMethod();
0065 
0066     Plasma::Containment *containmentById(uint id);
0067 
0068 private:
0069     QMenu *m_contextMenu{nullptr};
0070     QMetaMethod m_appletContainsMethod;
0071     QQuickItem *m_appletContainsMethodItem{nullptr};
0072 
0073     Latte::View *m_latteView;
0074 
0075     friend class Latte::View;
0076 };
0077 
0078 }
0079 }
0080 
0081 #endif // DOCKMENUMANAGER_H