EntryPushButton: Begin menus for deletion/favourites
This commit is contained in:
parent
2a9292958b
commit
e2c80b665e
@ -39,6 +39,9 @@ EntryPushButton::EntryPushButton(const EntryConfig &config) : QPushButton()
|
|||||||
}
|
}
|
||||||
this->config = config;
|
this->config = config;
|
||||||
connect(this, SIGNAL(clicked()), this, SLOT(emitOwnClicked()));
|
connect(this, SIGNAL(clicked()), this, SLOT(emitOwnClicked()));
|
||||||
|
|
||||||
|
systemEntryMenu.addAction("Add to favorites", [&] { emit addToFavourites(this->config); });
|
||||||
|
userEntryMenu.addAction("Delete", [&] { emit deleteRequested(this->config); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntryPushButton::emitOwnClicked()
|
void EntryPushButton::emitOwnClicked()
|
||||||
@ -72,12 +75,23 @@ void EntryPushButton::mousePressEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
dragStartPosition = event->pos();
|
dragStartPosition = event->pos();
|
||||||
}
|
}
|
||||||
|
if(event->button() == Qt::RightButton)
|
||||||
|
{
|
||||||
|
if(this->config.userEntry)
|
||||||
|
{
|
||||||
|
this->userEntryMenu.exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->systemEntryMenu.exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
}
|
||||||
return QPushButton::mousePressEvent(event);
|
return QPushButton::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntryPushButton::mouseMoveEvent(QMouseEvent *event)
|
void EntryPushButton::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(! this->config.userEntry)
|
if(!this->config.userEntry)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include "entryprovider.h"
|
#include "entryprovider.h"
|
||||||
|
|
||||||
#define ENTRYBUTTON_MIME_TYPE_STR "application/x-qsrun-entrypushbutton"
|
#define ENTRYBUTTON_MIME_TYPE_STR "application/x-qsrun-entrypushbutton"
|
||||||
@ -27,6 +29,8 @@ class EntryPushButton : public QPushButton
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
|
QMenu systemEntryMenu;
|
||||||
|
QMenu userEntryMenu;
|
||||||
EntryConfig config;
|
EntryConfig config;
|
||||||
QPoint dragStartPosition;
|
QPoint dragStartPosition;
|
||||||
|
|
||||||
@ -35,6 +39,8 @@ class EntryPushButton : public QPushButton
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked(const EntryConfig &config);
|
void clicked(const EntryConfig &config);
|
||||||
|
void deleteRequested(const EntryConfig &config);
|
||||||
|
void addToFavourites(const EntryConfig &config);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
Loading…
Reference in New Issue
Block a user