- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
|
|
|
|
#include "lts_tool_box.h"
|
|
|
|
#include "lts_drag_icon.h"
|
|
#include "lts_grid_layout.h"
|
|
|
|
#include <QMenu>
|
|
#include <QScrollArea>
|
|
#include <QScroller>
|
|
|
|
using namespace LtsWidgets;
|
|
|
|
LtsToolBox::LtsToolBox(QWidget* parent) : QToolBox(parent)
|
|
{
|
|
|
|
setMinimumSize(17, 200);
|
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
|
connect(this, &LtsToolBox::customContextMenuRequested, this, &LtsToolBox::showContextMenu);
|
|
|
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
}
|
|
|
|
LtsToolBox::~LtsToolBox() {}
|
|
|
|
void LtsToolBox::resizeEvent(QResizeEvent* e)
|
|
{
|
|
emit resized(e);
|
|
QToolBox::resizeEvent(e);
|
|
}
|
|
|
|
void LtsToolBox::addItem(QWidget* widget, const QString& text)
|
|
{
|
|
setMinimumSize(120, 100);
|
|
QToolBox::addItem(widget, text);
|
|
}
|
|
|
|
void LtsToolBox::showContextMenu(const QPoint& pos)
|
|
{
|
|
|
|
QPoint globalPos = this->mapToGlobal(pos);
|
|
|
|
QMenu myMenu;
|
|
myMenu.addAction(tr("Icon and Text"));
|
|
QAction* to = myMenu.addAction(tr("Text Only"));
|
|
QAction* io = myMenu.addAction(tr("Icon Only"));
|
|
|
|
QAction* selectedItem = myMenu.exec(globalPos);
|
|
if (selectedItem)
|
|
{
|
|
ButtonStyle newStyle = ButtonStyle::eTextNextToIcon;
|
|
if (selectedItem == to)
|
|
newStyle = ButtonStyle::eTextOnly;
|
|
if (selectedItem == io)
|
|
newStyle = ButtonStyle::eIconOnly;
|
|
|
|
for (int i = 0; i < count(); i++)
|
|
{
|
|
const QList<LtsDragIcon*> list = widget(i)->findChildren<LtsDragIcon*>();
|
|
for (LtsDragIcon* icon : list)
|
|
icon->setButtonStyle(newStyle);
|
|
LtsGridLayout* lay = qobject_cast<LtsGridLayout*>(widget(i)->layout());
|
|
if (lay)
|
|
lay->setAutoSize((newStyle == ButtonStyle::eIconOnly));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
}
|
|
}
|