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