forked from teamnwah/openmw-tes3coop
added scene tool mode context menu feature
This commit is contained in:
parent
0305ae3693
commit
eee972a1a4
2 changed files with 28 additions and 0 deletions
|
@ -3,10 +3,24 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
|
||||||
#include "scenetoolbar.hpp"
|
#include "scenetoolbar.hpp"
|
||||||
#include "modebutton.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)
|
void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode)
|
||||||
{
|
{
|
||||||
QString toolTip = mToolTip;
|
QString toolTip = mToolTip;
|
||||||
|
@ -15,6 +29,9 @@ void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode)
|
||||||
|
|
||||||
toolTip += "<p>(left click to change mode)";
|
toolTip += "<p>(left click to change mode)";
|
||||||
|
|
||||||
|
if (createContextMenu (0))
|
||||||
|
toolTip += "<br>(right click to access context menu)";
|
||||||
|
|
||||||
setToolTip (toolTip);
|
setToolTip (toolTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
namespace CSVWidget
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,16 @@ namespace CSVWidget
|
||||||
|
|
||||||
void adjustToolTip (const ModeButton *activeMode);
|
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:
|
public:
|
||||||
|
|
||||||
SceneToolMode (SceneToolbar *parent, const QString& toolTip);
|
SceneToolMode (SceneToolbar *parent, const QString& toolTip);
|
||||||
|
|
Loading…
Reference in a new issue