mirror of https://github.com/OpenMW/openmw.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
#include "scenetoolbar.hpp"
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#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)
|
|
: 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;
|
|
}
|
|
|
|
int CSVWidget::SceneToolbar::getIconSize() const
|
|
{
|
|
return mIconSize;
|
|
}
|