Skip to content

Commit

Permalink
open on drop
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Sep 5, 2018
1 parent bb6702f commit 7fd8732
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/app/qgsattributesformproperties.cpp
Expand Up @@ -142,7 +142,7 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::QmlWidget, QStringLiteral( "QmlWidget" ), tr( "QML Widget" ) );
itemData.setShowLabel( true );

QTreeWidgetItem *item = mAvailableWidgetsTree->addItem( catitem, itemData );
mAvailableWidgetsTree->addItem( catitem, itemData );
catitem ->setExpanded( true );
}

Expand Down Expand Up @@ -851,6 +851,10 @@ QTreeWidgetItem *DnDTree::addItem( QTreeWidgetItem *parent, QgsAttributesFormPro
case QgsAttributesFormProperties::DnDTreeItemData::Container:
newItem->setIcon( 0, QgsApplication::getThemeIcon( "/mContainerIcon.svg" ) );
break;

case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
newItem->setIcon( 0, QgsApplication::getThemeIcon( "/mQmlWidgetIcon.svg" ) );
break;
}
}
newItem->setData( 0, QgsAttributesFormProperties::DnDTreeRole, data );
Expand Down Expand Up @@ -914,16 +918,23 @@ bool DnDTree::dropMimeData( QTreeWidgetItem *parent, int index, const QMimeData
{
stream >> itemElement;

QTreeWidgetItem *newItem;

if ( parent )
{
addItem( parent, itemElement, index );
newItem = addItem( parent, itemElement, index );
bDropSuccessful = true;
}
else
{
addItem( invisibleRootItem(), itemElement, index );
newItem = addItem( invisibleRootItem(), itemElement, index );
bDropSuccessful = true;
}

if ( itemElement.type() == QgsAttributesFormProperties::DnDTreeItemData::QmlWidget )
{
onItemDoubleClicked( newItem, 0 );
}
}
}

Expand Down Expand Up @@ -1094,8 +1105,8 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
{
QDialog dlg;
dlg.resize( 600, 400 );
dlg.setWindowTitle( tr( "Configure QML Widget" ) );
dlg.setBaseSize( 600, 400 );
QFormLayout *layout = new QFormLayout() ;
dlg.setLayout( layout );
layout->addWidget( baseWidget );
Expand Down
71 changes: 71 additions & 0 deletions src/app/qgsqmlwidgetconfig.ui
@@ -0,0 +1,71 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Dialog</class>
<widget class="QDialog" name="Dialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="geometry" >
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 7fd8732

Please sign in to comment.