refactor:rename MenuManager to View::ContextMenu

pull/3/head
Michail Vourlakos 6 years ago
parent 85009494e7
commit 90a2bb3bc1

@ -20,8 +20,8 @@ set(lattedock-app_SRCS
waylandinterface.cpp
windowinfowrap.cpp
xwindowinterface.cpp
dock/contextmenu.cpp
dock/dockconfigview.cpp
dock/dockmenumanager.cpp
dock/docksecconfigview.cpp
dock/dockview.cpp
dock/effects.cpp

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dockmenumanager.h"
#include "contextmenu.h"
#include "dockview.h"
#include "visibilitymanager.h"
@ -38,23 +38,24 @@
#include <PlasmaQuick/AppletQuickItem>
namespace Latte {
namespace View {
DockMenuManager::DockMenuManager(DockView *view) :
ContextMenu::ContextMenu(Latte::DockView *view) :
QObject(view),
m_dockView(view)
{
}
DockMenuManager::~DockMenuManager()
ContextMenu::~ContextMenu()
{
}
QMenu *DockMenuManager::contextMenu()
QMenu *ContextMenu::menu()
{
return m_contextMenu;
}
void DockMenuManager::menuAboutToHide()
void ContextMenu::menuAboutToHide()
{
if (!m_dockView) {
return;
@ -66,10 +67,10 @@ void DockMenuManager::menuAboutToHide()
m_dockView->visibility()->setBlockHiding(false);
}
emit contextMenuChanged();
emit menuChanged();
}
bool DockMenuManager::mousePressEvent(QMouseEvent *event)
bool ContextMenu::mousePressEvent(QMouseEvent *event)
{
//qDebug() << "Step -1 ...";
@ -85,7 +86,7 @@ bool DockMenuManager::mousePressEvent(QMouseEvent *event)
//qDebug() << "Step 0.5 ...";
m_contextMenu->close();
m_contextMenu = 0;
emit contextMenuChanged();
emit menuChanged();
// PlasmaQuick::ContainmentView::mousePressEvent(event);
return false;
}
@ -281,7 +282,7 @@ bool DockMenuManager::mousePressEvent(QMouseEvent *event)
m_dockView->visibility()->setBlockHiding(true);
desktopMenu->popup(pos);
event->setAccepted(true);
emit contextMenuChanged();
emit menuChanged();
return false;
}
@ -292,13 +293,13 @@ bool DockMenuManager::mousePressEvent(QMouseEvent *event)
}
//qDebug() << "10 ...";
emit contextMenuChanged();
emit menuChanged();
return true;
// PlasmaQuick::ContainmentView::mousePressEvent(event);
}
//! update the appletContainsPos method from Panel view
void DockMenuManager::updateAppletContainsMethod()
void ContextMenu::updateAppletContainsMethod()
{
for (QQuickItem *item : m_dockView->contentItem()->childItems()) {
if (auto *metaObject = item->metaObject()) {
@ -319,7 +320,7 @@ void DockMenuManager::updateAppletContainsMethod()
}
}
void DockMenuManager::addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event)
void ContextMenu::addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event)
{
if (!m_dockView->containment()) {
return;
@ -402,7 +403,7 @@ void DockMenuManager::addAppletActions(QMenu *desktopMenu, Plasma::Applet *apple
}
}
void DockMenuManager::addContainmentActions(QMenu *desktopMenu, QEvent *event)
void ContextMenu::addContainmentActions(QMenu *desktopMenu, QEvent *event)
{
if (!m_dockView->containment()) {
return;
@ -452,7 +453,7 @@ void DockMenuManager::addContainmentActions(QMenu *desktopMenu, QEvent *event)
return;
}
Plasma::Containment *DockMenuManager::containmentById(uint id)
Plasma::Containment *ContextMenu::containmentById(uint id)
{
foreach (auto containment, m_dockView->corona()->containments()) {
if (id == containment->id()) {
@ -464,3 +465,4 @@ Plasma::Containment *DockMenuManager::containmentById(uint id)
}
}
}

@ -17,9 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DOCKMENUMANAGER_H
#define DOCKMENUMANAGER_H
#ifndef CONTEXTMENU_H
#define CONTEXTMENU_H
#include <QEvent>
#include <QMenu>
@ -38,21 +37,22 @@ class DockView;
}
namespace Latte {
namespace View {
class DockMenuManager : public QObject
class ContextMenu : public QObject
{
Q_OBJECT
public:
DockMenuManager(DockView *view);
~DockMenuManager() override;
ContextMenu(Latte::DockView *view);
~ContextMenu() override;
QMenu *contextMenu();
QMenu *menu();
bool mousePressEvent(QMouseEvent *event);
signals:
void contextMenuChanged();
void menuChanged();
private slots:
void menuAboutToHide();
@ -69,11 +69,12 @@ private:
QMetaMethod m_appletContainsMethod;
QQuickItem *m_appletContainsMethodItem{nullptr};
DockView *m_dockView;
Latte::DockView *m_dockView;
friend class DockView;
friend class Latte::DockView;
};
}
}
#endif // DOCKMENUMANAGER_H

@ -20,8 +20,8 @@
#include "dockview.h"
#include "contextmenu.h"
#include "dockconfigview.h"
#include "dockmenumanager.h"
#include "effects.h"
#include "positioner.h"
#include "visibilitymanager.h"
@ -59,7 +59,7 @@ namespace Latte {
//! are needed in order for window flags to be set correctly
DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindowBehavior)
: PlasmaQuick::ContainmentView(corona),
m_menuManager(new DockMenuManager(this)),
m_contextMenu(new View::ContextMenu(this)),
m_effects(new View::Effects(this)),
m_positioner(new View::Positioner(this)) //needs to be created after Effects becuase it catches some of its signals
{
@ -149,8 +149,8 @@ DockView::~DockView()
m_configView->setVisible(false);//hide();
}
if (m_menuManager) {
delete m_menuManager;
if (m_contextMenu) {
delete m_contextMenu;
}
//needs to be deleted before Effects becuase it catches some of its signals
@ -188,7 +188,7 @@ void DockView::init()
connect(this, SIGNAL(normalThicknessChanged()), corona(), SIGNAL(availableScreenRectChanged()));
connect(m_menuManager, &DockMenuManager::contextMenuChanged, this, &DockView::contextMenuIsShownChanged);
connect(m_contextMenu, &View::ContextMenu::menuChanged, this, &DockView::contextMenuIsShownChanged);
///!!!!!
rootContext()->setContextProperty(QStringLiteral("dock"), this);
@ -434,11 +434,11 @@ void DockView::setAlternativesIsShown(bool show)
bool DockView::contextMenuIsShown() const
{
if (!m_menuManager) {
if (!m_contextMenu) {
return false;
}
return m_menuManager->contextMenu();
return m_contextMenu->menu();
}
int DockView::currentThickness() const
@ -1027,7 +1027,7 @@ void DockView::restoreGrabItemBehavior()
//!BEGIN overriding context menus behavior
void DockView::mousePressEvent(QMouseEvent *event)
{
bool result = m_menuManager->mousePressEvent(event);
bool result = m_contextMenu->mousePressEvent(event);
emit contextMenuIsShownChanged();
if (result) {

@ -52,8 +52,11 @@ class PlasmaShellSurface;
}
namespace Latte {
class DockMenuManager;
class Layout;
namespace View {
class ContextMenu;
}
}
namespace Latte {
@ -264,7 +267,7 @@ private:
Layout *m_managedLayout{nullptr};
QPointer<PlasmaQuick::ConfigView> m_configView;
QPointer<DockMenuManager> m_menuManager;
QPointer<View::ContextMenu> m_contextMenu;
QPointer<View::Effects> m_effects;
QPointer<View::Positioner> m_positioner;
QPointer<VisibilityManager> m_visibility;

Loading…
Cancel
Save