1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 04:15:31 +00:00

added scene tool mode context menu feature

This commit is contained in:
Marc Zinnschlag 2016-01-19 12:47:11 +01:00
parent 0305ae3693
commit eee972a1a4
2 changed files with 28 additions and 0 deletions

View file

@ -3,10 +3,24 @@
#include <QHBoxLayout>
#include <QFrame>
#include <QSignalMapper>
#include <QMenu>
#include <QContextMenuEvent>
#include "scenetoolbar.hpp"
#include "modebutton.hpp"
void CSVWidget::SceneToolMode::contextMenuEvent (QContextMenuEvent *event)
{
QMenu menu (this);
if (createContextMenu (&menu))
menu.exec (event->globalPos());
}
bool CSVWidget::SceneToolMode::createContextMenu (QMenu *menu)
{
return false;
}
void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode)
{
QString toolTip = mToolTip;
@ -15,6 +29,9 @@ void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode)
toolTip += "<p>(left click to change mode)";
if (createContextMenu (0))
toolTip += "<br>(right click to access context menu)";
setToolTip (toolTip);
}

View file

@ -6,6 +6,7 @@
#include <map>
class QHBoxLayout;
class QMenu;
namespace CSVWidget
{
@ -29,6 +30,16 @@ namespace CSVWidget
void adjustToolTip (const ModeButton *activeMode);
virtual void contextMenuEvent (QContextMenuEvent *event);
/// Add context menu items to \a menu. Default-implementation: return false
///
/// \attention menu can be a 0-pointer
///
/// \return Have there been any menu items to be added (if menu is 0 and there
/// items to be added, the function must return true anyway.
virtual bool createContextMenu (QMenu *menu);
public:
SceneToolMode (SceneToolbar *parent, const QString& toolTip);