Skip to content

Commit 7fd8732

Browse files
committed
open on drop
1 parent bb6702f commit 7fd8732

File tree

2 files changed

+86
-4
lines changed

2 files changed

+86
-4
lines changed

src/app/qgsattributesformproperties.cpp

+15-4
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
142142
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::QmlWidget, QStringLiteral( "QmlWidget" ), tr( "QML Widget" ) );
143143
itemData.setShowLabel( true );
144144

145-
QTreeWidgetItem *item = mAvailableWidgetsTree->addItem( catitem, itemData );
145+
mAvailableWidgetsTree->addItem( catitem, itemData );
146146
catitem ->setExpanded( true );
147147
}
148148

@@ -851,6 +851,10 @@ QTreeWidgetItem *DnDTree::addItem( QTreeWidgetItem *parent, QgsAttributesFormPro
851851
case QgsAttributesFormProperties::DnDTreeItemData::Container:
852852
newItem->setIcon( 0, QgsApplication::getThemeIcon( "/mContainerIcon.svg" ) );
853853
break;
854+
855+
case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
856+
newItem->setIcon( 0, QgsApplication::getThemeIcon( "/mQmlWidgetIcon.svg" ) );
857+
break;
854858
}
855859
}
856860
newItem->setData( 0, QgsAttributesFormProperties::DnDTreeRole, data );
@@ -914,16 +918,23 @@ bool DnDTree::dropMimeData( QTreeWidgetItem *parent, int index, const QMimeData
914918
{
915919
stream >> itemElement;
916920

921+
QTreeWidgetItem *newItem;
922+
917923
if ( parent )
918924
{
919-
addItem( parent, itemElement, index );
925+
newItem = addItem( parent, itemElement, index );
920926
bDropSuccessful = true;
921927
}
922928
else
923929
{
924-
addItem( invisibleRootItem(), itemElement, index );
930+
newItem = addItem( invisibleRootItem(), itemElement, index );
925931
bDropSuccessful = true;
926932
}
933+
934+
if ( itemElement.type() == QgsAttributesFormProperties::DnDTreeItemData::QmlWidget )
935+
{
936+
onItemDoubleClicked( newItem, 0 );
937+
}
927938
}
928939
}
929940

@@ -1094,8 +1105,8 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
10941105
case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
10951106
{
10961107
QDialog dlg;
1108+
dlg.resize( 600, 400 );
10971109
dlg.setWindowTitle( tr( "Configure QML Widget" ) );
1098-
dlg.setBaseSize( 600, 400 );
10991110
QFormLayout *layout = new QFormLayout() ;
11001111
dlg.setLayout( layout );
11011112
layout->addWidget( baseWidget );

src/app/qgsqmlwidgetconfig.ui

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<ui version="4.0" >
2+
<author></author>
3+
<comment></comment>
4+
<exportmacro></exportmacro>
5+
<class>Dialog</class>
6+
<widget class="QDialog" name="Dialog" >
7+
<property name="geometry" >
8+
<rect>
9+
<x>0</x>
10+
<y>0</y>
11+
<width>400</width>
12+
<height>300</height>
13+
</rect>
14+
</property>
15+
<property name="windowTitle" >
16+
<string>Dialog</string>
17+
</property>
18+
<widget class="QDialogButtonBox" name="buttonBox" >
19+
<property name="geometry" >
20+
<rect>
21+
<x>30</x>
22+
<y>240</y>
23+
<width>341</width>
24+
<height>32</height>
25+
</rect>
26+
</property>
27+
<property name="orientation" >
28+
<enum>Qt::Horizontal</enum>
29+
</property>
30+
<property name="standardButtons" >
31+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
32+
</property>
33+
</widget>
34+
</widget>
35+
<pixmapfunction></pixmapfunction>
36+
<resources/>
37+
<connections>
38+
<connection>
39+
<sender>buttonBox</sender>
40+
<signal>accepted()</signal>
41+
<receiver>Dialog</receiver>
42+
<slot>accept()</slot>
43+
<hints>
44+
<hint type="sourcelabel" >
45+
<x>248</x>
46+
<y>254</y>
47+
</hint>
48+
<hint type="destinationlabel" >
49+
<x>157</x>
50+
<y>274</y>
51+
</hint>
52+
</hints>
53+
</connection>
54+
<connection>
55+
<sender>buttonBox</sender>
56+
<signal>rejected()</signal>
57+
<receiver>Dialog</receiver>
58+
<slot>reject()</slot>
59+
<hints>
60+
<hint type="sourcelabel" >
61+
<x>316</x>
62+
<y>260</y>
63+
</hint>
64+
<hint type="destinationlabel" >
65+
<x>286</x>
66+
<y>274</y>
67+
</hint>
68+
</hints>
69+
</connection>
70+
</connections>
71+
</ui>

0 commit comments

Comments
 (0)