mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 21:45:32 +00:00
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 "../../model/prefs/shortcut.hpp"
|
||||
#include "../../model/prefs/shortcuteventhandler.hpp"
|
||||
|
||||
#include "worldspacewidget.hpp"
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
OrbitCameraMode::OrbitCameraMode(WorldspaceWidget* worldspaceWidget, const QIcon& icon, const QString& tooltip,
|
||||
QWidget* parent)
|
||||
OrbitCameraMode::OrbitCameraMode(WorldspaceWidget* worldspaceWidget, CSMPrefs::ShortcutEventHandler* handler,
|
||||
const QIcon& icon, const QString& tooltip, QWidget* parent)
|
||||
: ModeButton(icon, tooltip, parent)
|
||||
, mWorldspaceWidget(worldspaceWidget)
|
||||
, mShortcutHandler(handler)
|
||||
, 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)
|
||||
{
|
||||
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()));
|
||||
|
||||
mCenterShortcut->enable(true);
|
||||
}
|
||||
|
||||
void OrbitCameraMode::deactivate(CSVWidget::SceneToolbar* toolbar)
|
||||
{
|
||||
mCenterShortcut->enable(false);
|
||||
}
|
||||
|
||||
bool OrbitCameraMode::createContextMenu(QMenu* menu)
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
#include "../widget/modebutton.hpp"
|
||||
|
||||
namespace CSMPrefs
|
||||
{
|
||||
class Shortcut;
|
||||
class ShortcutEventHandler;
|
||||
}
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
class WorldspaceWidget;
|
||||
|
@ -13,16 +19,20 @@ namespace CSVRender
|
|||
|
||||
public:
|
||||
|
||||
OrbitCameraMode(WorldspaceWidget* worldspaceWidget, const QIcon& icon, const QString& tooltip = "",
|
||||
QWidget* parent = 0);
|
||||
OrbitCameraMode(WorldspaceWidget* worldspaceWidget, CSMPrefs::ShortcutEventHandler* shortcutHandler,
|
||||
const QIcon& icon, const QString& tooltip = "", QWidget* parent = 0);
|
||||
~OrbitCameraMode();
|
||||
|
||||
virtual void activate(CSVWidget::SceneToolbar* toolbar);
|
||||
virtual void deactivate(CSVWidget::SceneToolbar* toolbar);
|
||||
virtual bool createContextMenu(QMenu* menu);
|
||||
|
||||
private:
|
||||
|
||||
WorldspaceWidget* mWorldspaceWidget;
|
||||
CSMPrefs::ShortcutEventHandler* mShortcutHandler;
|
||||
QAction* mCenterOnSelection;
|
||||
CSMPrefs::Shortcut* mCenterShortcut;
|
||||
|
||||
private slots:
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
|||
"<li>Hold shift to speed up movement</li>"
|
||||
"</ul>");
|
||||
tool->addButton(
|
||||
new CSVRender::OrbitCameraMode(this, QIcon(":scenetoolbar/orbiting-camera"),
|
||||
new CSVRender::OrbitCameraMode(this, mShortcutHandler, QIcon(":scenetoolbar/orbiting-camera"),
|
||||
"Orbiting Camera"
|
||||
"<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>"
|
||||
|
|
Loading…
Reference in a new issue