From 74c9ba962ffe142b04f77fd831438a75eec7b46b Mon Sep 17 00:00:00 2001 From: Louie S Date: Fri, 1 Mar 2024 18:22:59 -0500 Subject: Add right-click skeletons to groups --- src/group.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src/group.cpp') diff --git a/src/group.cpp b/src/group.cpp index 781fb98..5bc6b7c 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -1,6 +1,9 @@ #include +#include #include +#include + #include "group.h" Group::Group(int id, QString name, QString column, QString link, bool hidden) : @@ -14,10 +17,46 @@ Group::Group(int id, QString name, QString column, QString link, bool hidden) : QLabel *name_label = new QLabel(this->name); name_label->setTextInteractionFlags(Qt::TextSelectableByMouse); + name_label->setToolTip("Right-Click for actions"); + name_label->setContextMenuPolicy(Qt::CustomContextMenu); + //name_label->customContextMenuRequested(const QPoint &pos) + QObject::connect(name_label, + SIGNAL(customContextMenuRequested(const QPoint &)), + SLOT(showContextMenu())); QFont name_font = QFont("Arial", 13); name_font.setUnderline(true); - name_label->setFont(name_font); + this->addWidget(name_label); } + +void Group::showContextMenu() { + QMenu menu; + + QAction *add_entry_act = new QAction("Add Entry"); + QObject::connect(add_entry_act, &QAction::triggered, this, &Group::addEntry); + menu.addAction(add_entry_act); + + QAction *edit_group_act = new QAction("Edit Group"); + QObject::connect(edit_group_act, &QAction::triggered, this, &Group::editGroup); + menu.addAction(edit_group_act); + + QAction *del_group_act = new QAction("Remove Group"); + QObject::connect(del_group_act, &QAction::triggered, this, &Group::removeGroup); + menu.addAction(del_group_act); + + menu.exec(QCursor::pos()); +} + +void Group::addEntry() { + qDebug() << "WIP"; +} + +void Group::editGroup() { + qDebug() << "WIP"; +} + +void Group::removeGroup() { + qDebug() << "WIP"; +} -- cgit