2013-09-28 07:25:54 +00:00
|
|
|
#include "scenetoolbar.hpp"
|
|
|
|
|
2013-09-28 09:06:56 +00:00
|
|
|
#include <QVBoxLayout>
|
2016-07-27 04:24:16 +00:00
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2016-07-27 04:24:16 +00:00
|
|
|
#include "../../model/prefs/shortcut.hpp"
|
2013-09-28 09:06:56 +00:00
|
|
|
|
|
|
|
#include "scenetool.hpp"
|
|
|
|
|
2014-07-14 09:06:12 +00:00
|
|
|
void CSVWidget::SceneToolbar::focusInEvent(QFocusEvent* event)
|
|
|
|
{
|
|
|
|
QWidget::focusInEvent(event);
|
|
|
|
|
|
|
|
if (mLayout->count())
|
|
|
|
dynamic_cast<QWidgetItem&>(*mLayout->itemAt(0)).widget()->setFocus();
|
|
|
|
}
|
|
|
|
|
2014-07-08 10:39:12 +00:00
|
|
|
CSVWidget::SceneToolbar::SceneToolbar(int buttonSize, QWidget* parent)
|
2014-04-03 11:30:22 +00:00
|
|
|
: QWidget(parent)
|
|
|
|
, mButtonSize(buttonSize)
|
|
|
|
, mIconSize(buttonSize - 6)
|
2013-09-28 07:25:54 +00:00
|
|
|
{
|
2013-10-07 09:14:11 +00:00
|
|
|
setFixedWidth(mButtonSize);
|
2013-09-28 09:06:56 +00:00
|
|
|
|
|
|
|
mLayout = new QVBoxLayout(this);
|
|
|
|
mLayout->setAlignment(Qt::AlignTop);
|
2013-09-28 07:25:54 +00:00
|
|
|
|
2013-09-28 09:06:56 +00:00
|
|
|
mLayout->setContentsMargins(QMargins(0, 0, 0, 0));
|
|
|
|
|
|
|
|
setLayout(mLayout);
|
2014-07-14 11:49:55 +00:00
|
|
|
|
2016-07-27 04:24:16 +00:00
|
|
|
CSMPrefs::Shortcut* focusSceneShortcut = new CSMPrefs::Shortcut("scene-focus-toolbar", this);
|
2022-08-23 02:28:58 +00:00
|
|
|
connect(focusSceneShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this, &SceneToolbar::focusSceneRequest);
|
2013-09-28 07:25:54 +00:00
|
|
|
}
|
2013-09-28 09:06:56 +00:00
|
|
|
|
2014-11-03 12:18:53 +00:00
|
|
|
void CSVWidget::SceneToolbar::addTool(SceneTool* tool, SceneTool* insertPoint)
|
2013-09-28 09:06:56 +00:00
|
|
|
{
|
2014-11-03 12:18:53 +00:00
|
|
|
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);
|
2013-10-07 09:14:11 +00:00
|
|
|
}
|
|
|
|
|
2014-07-08 10:39:12 +00:00
|
|
|
int CSVWidget::SceneToolbar::getButtonSize() const
|
2013-10-07 09:14:11 +00:00
|
|
|
{
|
|
|
|
return mButtonSize;
|
2014-04-03 11:00:19 +00:00
|
|
|
}
|
|
|
|
|
2014-07-08 10:39:12 +00:00
|
|
|
int CSVWidget::SceneToolbar::getIconSize() const
|
2014-04-03 11:00:19 +00:00
|
|
|
{
|
|
|
|
return mIconSize;
|
2014-07-14 11:49:55 +00:00
|
|
|
}
|