forked from teamnwah/openmw-tes3coop
Added orbit "center on selection" shortcut.
This commit is contained in:
parent
e8626e588a
commit
d8fa3fd1de
3 changed files with 36 additions and 6 deletions
|
@ -2,22 +2,42 @@
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include "../../model/prefs/shortcut.hpp"
|
||||||
|
#include "../../model/prefs/shortcuteventhandler.hpp"
|
||||||
|
|
||||||
#include "worldspacewidget.hpp"
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
OrbitCameraMode::OrbitCameraMode(WorldspaceWidget* worldspaceWidget, const QIcon& icon, const QString& tooltip,
|
OrbitCameraMode::OrbitCameraMode(WorldspaceWidget* worldspaceWidget, CSMPrefs::ShortcutEventHandler* handler,
|
||||||
QWidget* parent)
|
const QIcon& icon, const QString& tooltip, QWidget* parent)
|
||||||
: ModeButton(icon, tooltip, parent)
|
: ModeButton(icon, tooltip, parent)
|
||||||
, mWorldspaceWidget(worldspaceWidget)
|
, mWorldspaceWidget(worldspaceWidget)
|
||||||
|
, mShortcutHandler(handler)
|
||||||
, mCenterOnSelection(0)
|
, mCenterOnSelection(0)
|
||||||
{
|
{
|
||||||
|
mCenterShortcut = new CSMPrefs::Shortcut("orbit-center-selection", this);
|
||||||
|
mCenterShortcut->enable(false);
|
||||||
|
mShortcutHandler->addShortcut(mCenterShortcut);
|
||||||
|
connect(mCenterShortcut, SIGNAL(activated()), this, SLOT(centerSelection()));
|
||||||
|
}
|
||||||
|
|
||||||
|
OrbitCameraMode::~OrbitCameraMode()
|
||||||
|
{
|
||||||
|
mShortcutHandler->removeShortcut(mCenterShortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrbitCameraMode::activate(CSVWidget::SceneToolbar* toolbar)
|
void OrbitCameraMode::activate(CSVWidget::SceneToolbar* toolbar)
|
||||||
{
|
{
|
||||||
mCenterOnSelection = new QAction("Center on selected object", this);
|
mCenterOnSelection = new QAction("Center on selected object\t" + mCenterShortcut->toString(), this);
|
||||||
connect(mCenterOnSelection, SIGNAL(triggered()), this, SLOT(centerSelection()));
|
connect(mCenterOnSelection, SIGNAL(triggered()), this, SLOT(centerSelection()));
|
||||||
|
|
||||||
|
mCenterShortcut->enable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OrbitCameraMode::deactivate(CSVWidget::SceneToolbar* toolbar)
|
||||||
|
{
|
||||||
|
mCenterShortcut->enable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OrbitCameraMode::createContextMenu(QMenu* menu)
|
bool OrbitCameraMode::createContextMenu(QMenu* menu)
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
|
|
||||||
#include "../widget/modebutton.hpp"
|
#include "../widget/modebutton.hpp"
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class Shortcut;
|
||||||
|
class ShortcutEventHandler;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
class WorldspaceWidget;
|
class WorldspaceWidget;
|
||||||
|
@ -13,16 +19,20 @@ namespace CSVRender
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OrbitCameraMode(WorldspaceWidget* worldspaceWidget, const QIcon& icon, const QString& tooltip = "",
|
OrbitCameraMode(WorldspaceWidget* worldspaceWidget, CSMPrefs::ShortcutEventHandler* shortcutHandler,
|
||||||
QWidget* parent = 0);
|
const QIcon& icon, const QString& tooltip = "", QWidget* parent = 0);
|
||||||
|
~OrbitCameraMode();
|
||||||
|
|
||||||
virtual void activate(CSVWidget::SceneToolbar* toolbar);
|
virtual void activate(CSVWidget::SceneToolbar* toolbar);
|
||||||
|
virtual void deactivate(CSVWidget::SceneToolbar* toolbar);
|
||||||
virtual bool createContextMenu(QMenu* menu);
|
virtual bool createContextMenu(QMenu* menu);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
WorldspaceWidget* mWorldspaceWidget;
|
WorldspaceWidget* mWorldspaceWidget;
|
||||||
|
CSMPrefs::ShortcutEventHandler* mShortcutHandler;
|
||||||
QAction* mCenterOnSelection;
|
QAction* mCenterOnSelection;
|
||||||
|
CSMPrefs::Shortcut* mCenterShortcut;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
||||||
"<li>Hold shift to speed up movement</li>"
|
"<li>Hold shift to speed up movement</li>"
|
||||||
"</ul>");
|
"</ul>");
|
||||||
tool->addButton(
|
tool->addButton(
|
||||||
new CSVRender::OrbitCameraMode(this, QIcon(":scenetoolbar/orbiting-camera"),
|
new CSVRender::OrbitCameraMode(this, mShortcutHandler, QIcon(":scenetoolbar/orbiting-camera"),
|
||||||
"Orbiting Camera"
|
"Orbiting Camera"
|
||||||
"<ul><li>Always facing the centre point</li>"
|
"<ul><li>Always facing the centre point</li>"
|
||||||
"<li>Rotate around the centre point via WASD or by moving the mouse while holding the left button</li>"
|
"<li>Rotate around the centre point via WASD or by moving the mouse while holding the left button</li>"
|
||||||
|
|
Loading…
Reference in a new issue