first re-commit.
This commit is contained in:
68
widgets/xqcontextmenu.cpp
Normal file
68
widgets/xqcontextmenu.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx xtree
|
||||
Copyright © 2024-2025 c.holzheuer
|
||||
christoph.holzheuer@gmail.com
|
||||
|
||||
This program 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.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <xqcontextmenu.h>
|
||||
|
||||
|
||||
XQContextMenu::XQContextMenu(const QString& title, QWidget* parent )
|
||||
: QMenu( title, parent )
|
||||
{
|
||||
/*
|
||||
QAction* titleDummy = new QAction(title,this);
|
||||
QWidget::addAction(titleDummy);
|
||||
addSeparator();
|
||||
titleDummy->setEnabled(false);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
XQContextMenu::XQContextMenu(QWidget* parent)
|
||||
: QMenu( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandType, bool enabled)
|
||||
{
|
||||
QAction* newAction = new QAction(text, this);
|
||||
newAction->setData(commandType);
|
||||
_actionMap[commandType] = newAction;
|
||||
QWidget::addAction(newAction);
|
||||
setActionEnabled( commandType, enabled );
|
||||
}
|
||||
|
||||
|
||||
void XQContextMenu::addAction(const QString& iconKey, const QString& name, XQCommand::CmdType commandType, bool enabled)
|
||||
{
|
||||
addAction(XQAppData::typeIcon( iconKey), name, commandType, enabled );
|
||||
}
|
||||
|
||||
|
||||
void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand::CmdType commandType, bool enabled)
|
||||
{
|
||||
QAction* newAction = new QAction(icon, text, this);
|
||||
newAction->setData(commandType);
|
||||
_actionMap[commandType] = newAction;
|
||||
QWidget::addAction(newAction);
|
||||
setActionEnabled( commandType, enabled );
|
||||
}
|
||||
|
||||
|
||||
void XQContextMenu::setActionEnabled(XQCommand::CmdType commandType, bool enabled)
|
||||
{
|
||||
if( _actionMap.contains(commandType) )
|
||||
_actionMap[commandType]->setEnabled( enabled );
|
||||
}
|
Reference in New Issue
Block a user