2018-02-03 16:00:44 +03:00
/*
* Copyright 2018 Michail Vourlakos < mvourlakos @ gmail . com >
*
* This file is part of Latte - Dock
*
* Latte - Dock is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation ; either version 2 of
* the License , or ( at your option ) any later version .
*
* Latte - Dock is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2018-12-02 01:53:40 +03:00
# ifndef CONTEXTMENU_H
# define CONTEXTMENU_H
2018-02-03 16:00:44 +03:00
2018-12-02 03:05:52 +03:00
// Qt
2018-02-03 16:00:44 +03:00
# include <QEvent>
# include <QMenu>
# include <QMetaMethod>
# include <QQuickItem>
2020-07-11 20:13:19 +03:00
# include <QQuickView>
2020-07-14 09:28:19 +03:00
# include <QPointer>
2018-02-03 16:00:44 +03:00
# include <QMouseEvent>
# include <QObject>
namespace Plasma {
class Applet ;
class Containment ;
}
namespace Latte {
2018-12-06 13:15:58 +03:00
class View ;
2018-02-03 16:00:44 +03:00
}
namespace Latte {
2018-12-06 12:37:14 +03:00
namespace ViewPart {
2018-02-03 16:00:44 +03:00
2018-12-02 01:53:40 +03:00
class ContextMenu : public QObject
2018-07-03 22:15:45 +03:00
{
2018-02-03 16:00:44 +03:00
Q_OBJECT
public :
2018-12-06 13:15:58 +03:00
ContextMenu ( Latte : : View * view ) ;
2018-12-02 01:53:40 +03:00
~ ContextMenu ( ) override ;
2018-02-03 16:00:44 +03:00
2018-12-02 01:53:40 +03:00
QMenu * menu ( ) ;
2018-02-03 16:00:44 +03:00
bool mousePressEvent ( QMouseEvent * event ) ;
2020-07-11 20:13:19 +03:00
bool mousePressEventForContainmentMenu ( QQuickView * view , QMouseEvent * event ) ;
2018-02-03 16:00:44 +03:00
signals :
2018-12-02 01:53:40 +03:00
void menuChanged ( ) ;
2018-02-03 16:00:44 +03:00
private slots :
void menuAboutToHide ( ) ;
private :
void addAppletActions ( QMenu * desktopMenu , Plasma : : Applet * applet , QEvent * event ) ;
void addContainmentActions ( QMenu * desktopMenu , QEvent * event ) ;
void updateAppletContainsMethod ( ) ;
2020-04-11 00:41:29 +03:00
QPoint popUpRelevantToParent ( const QRect & parentItem , const QRect popUpRect ) ;
QPoint popUpRelevantToGlobalPoint ( const QRect & parentItem , const QRect popUpRect ) ;
QPoint popUpTopLeft ( Plasma : : Applet * applet , const QRect popUpRect ) ;
2020-04-08 20:31:29 +03:00
2018-02-03 16:00:44 +03:00
Plasma : : Containment * containmentById ( uint id ) ;
2020-04-08 20:31:29 +03:00
2018-02-03 16:00:44 +03:00
private :
2020-07-11 20:57:54 +03:00
QPointer < QMenu > m_contextMenu ;
2018-02-03 16:00:44 +03:00
QMetaMethod m_appletContainsMethod ;
QQuickItem * m_appletContainsMethodItem { nullptr } ;
2018-12-06 13:51:15 +03:00
Latte : : View * m_latteView ;
2018-02-03 16:00:44 +03:00
2018-12-06 13:15:58 +03:00
friend class Latte : : View ;
2018-02-03 16:00:44 +03:00
} ;
2018-12-02 01:53:40 +03:00
}
2018-02-03 16:00:44 +03:00
}
# endif // DOCKMENUMANAGER_H