1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 11:53:53 +00:00
openmw/apps/opencs/view/widget/scenetoolbar.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
1.4 KiB
C++
Raw Normal View History

#include "scenetoolbar.hpp"
#include <QVBoxLayout>
2022-10-19 17:02:00 +00:00
#include <memory>
#include "../../model/prefs/shortcut.hpp"
#include "scenetool.hpp"
void CSVWidget::SceneToolbar::focusInEvent(QFocusEvent* event)
{
QWidget::focusInEvent(event);
if (mLayout->count())
dynamic_cast<QWidgetItem&>(*mLayout->itemAt(0)).widget()->setFocus();
}
CSVWidget::SceneToolbar::SceneToolbar(int buttonSize, QWidget* parent)
2014-04-03 11:30:22 +00:00
: QWidget(parent)
, mButtonSize(buttonSize)
, mIconSize(buttonSize - 6)
{
setFixedWidth(mButtonSize);
mLayout = new QVBoxLayout(this);
mLayout->setAlignment(Qt::AlignTop);
mLayout->setContentsMargins(QMargins(0, 0, 0, 0));
setLayout(mLayout);
CSMPrefs::Shortcut* focusSceneShortcut = new CSMPrefs::Shortcut("scene-focus-toolbar", this);
connect(focusSceneShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this, &SceneToolbar::focusSceneRequest);
}
void CSVWidget::SceneToolbar::addTool(SceneTool* tool, SceneTool* insertPoint)
{
if (!insertPoint)
mLayout->addWidget(tool, 0, Qt::AlignTop);
else
{
int index = mLayout->indexOf(insertPoint);
mLayout->insertWidget(index + 1, tool, 0, Qt::AlignTop);
}
}
void CSVWidget::SceneToolbar::removeTool(SceneTool* tool)
{
mLayout->removeWidget(tool);
}
int CSVWidget::SceneToolbar::getButtonSize() const
{
return mButtonSize;
2014-04-03 11:00:19 +00:00
}
int CSVWidget::SceneToolbar::getIconSize() const
2014-04-03 11:00:19 +00:00
{
return mIconSize;
}