8#include <QtDesigner/abstractformeditor.h>
9#include <QtDesigner/abstractformwindowmanager.h>
11#include <iconloader_p.h>
12#include <qdesigner_utils_p.h>
14#include <QtGui/qevent.h>
15#include <QtWidgets/qboxlayout.h>
16#include <QtWidgets/qapplication.h>
17#include <QtWidgets/qtoolbar.h>
18#include <QtWidgets/qlineedit.h>
19#include <QtGui/qicon.h>
26
27
28
29
34 { setFocusPolicy(Qt::NoFocus); }
41 const Qt::FocusPolicy m_defaultFocusPolicy;
47 setFocus(Qt::OtherFocusReason);
48 QLineEdit::mousePressEvent(e);
56 const Qt::FocusReason reason = e->reason();
57 if (reason == Qt::ActiveWindowFocusReason || reason == Qt::PopupFocusReason) {
58 const QPoint mousePos = mapFromGlobal(QCursor::pos());
59 const bool refuse = !geometry().contains(mousePos);
65 QLineEdit::focusInEvent(e);
68WidgetBox::WidgetBox(QDesignerFormEditorInterface *core, QWidget *parent, Qt::WindowFlags flags)
69 : QDesignerWidgetBox(parent, flags),
71 m_view(
new WidgetBoxTreeWidget(m_core))
74 QVBoxLayout *l =
new QVBoxLayout(
this);
75 l->setContentsMargins(QMargins());
79 QToolBar *toolBar =
new QToolBar(
this);
80 QLineEdit *filterWidget =
new WidgetBoxFilterLineEdit(toolBar);
81 filterWidget->setPlaceholderText(tr(
"Filter"));
82 filterWidget->setClearButtonEnabled(
true);
83 connect(filterWidget, &QLineEdit::textChanged, m_view, &WidgetBoxTreeWidget::filter);
84 toolBar->addWidget(filterWidget);
85 l->addWidget(toolBar);
88 connect(m_view, &WidgetBoxTreeWidget::widgetBoxPressed,
89 this, &WidgetBox::handleMousePress);
92 setAcceptDrops (
true);
102void WidgetBox::handleMousePress(
const QString &name,
const QString &xml,
const QPoint &global_mouse_pos)
104 if (QApplication::mouseButtons() != Qt::LeftButton)
107 DomUI *ui = xmlToUi(name, xml,
true);
110 QList<QDesignerDnDItemInterface*> item_list;
112 m_core->formWindowManager()->dragItems(item_list);
122 return m_view->category(cat_idx);
127 m_view->addCategory(cat);
142 return m_view->widget(cat_idx, wgt_idx);
147 m_view->addWidget(cat_idx, wgt);
157 m_view->dropWidgets(item_list);
162 m_view->setFileName(file_name);
167 return m_view->fileName();
172 return m_view->load(loadMode());
177 return m_view->loadContents(contents);
186 bool acceptEventsFromWidgetBox)
188 const QDesignerMimeData *mimeData = qobject_cast<
const QDesignerMimeData *>(event->mimeData());
194 if (!acceptEventsFromWidgetBox) {
195 const bool fromWidgetBox = !mimeData->items().first()->widget();
202 mimeData->acceptEvent(event);
210 checkDragEvent(event,
true);
215 checkDragEvent(event,
true);
220 const QDesignerMimeData *mimeData = checkDragEvent(event,
false);
224 dropWidgets(mimeData->items(), event->position().toPoint());
225 QDesignerMimeData::removeMovedWidgetsFromSourceForm(mimeData->items());
228QIcon
WidgetBox::iconForWidget(
const QString &className,
const QString &category)
const
231 if (!findWidget(
this, className, category, &widgetData))
233 return m_view->iconForWidget(widgetData.iconName());
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static const QDesignerMimeData * checkDragEvent(QDropEvent *event, bool acceptEventsFromWidgetBox)