diff options
author | Roland Knall <roland.knall@br-automation.com> | 2017-11-20 09:56:26 +0100 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2017-11-20 14:56:23 +0000 |
commit | 6917ec769e4d23fe2fa212bec69c9ce9b65c1671 (patch) | |
tree | 15cc5ebc29c7a4dede71c8d174086b5915fb0166 /ui | |
parent | 4fbb2df3cd160aba589dc0a576b44c2a63b4a6fe (diff) |
Qt: Fix various smalles issues with drag-drop
Cleanup adding a filter and implement some
sanity checks in the drop code
Change-Id: I1778be16abdea3f93ed11fc610962c4a23f10a2f
Reviewed-on: https://code.wireshark.org/review/24505
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/filter_expression_frame.cpp | 3 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 1 | ||||
-rw-r--r-- | ui/qt/widgets/drag_drop_toolbar.cpp | 39 | ||||
-rw-r--r-- | ui/qt/widgets/drag_drop_toolbar.h | 2 |
4 files changed, 35 insertions, 10 deletions
diff --git a/ui/qt/filter_expression_frame.cpp b/ui/qt/filter_expression_frame.cpp index 8b68b8e5cf..942637484d 100644 --- a/ui/qt/filter_expression_frame.cpp +++ b/ui/qt/filter_expression_frame.cpp @@ -63,6 +63,9 @@ void FilterExpressionFrame::addExpression(const QString filter_text) editExpression_ = -1; ui->displayFilterLineEdit->setText(filter_text); + + if (! isVisible()) + animatedShow(); } void FilterExpressionFrame::editExpression(int exprIdx) diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 40b338a0e6..e86d885f40 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -1744,7 +1744,6 @@ void MainWindow::on_actionDisplayFilterExpression_triggered() void MainWindow::on_actionNewDisplayFilterExpression_triggered() { main_ui_->filterExpressionFrame->addExpression(df_combo_box_->lineEdit()->text()); - showAccordionFrame(main_ui_->filterExpressionFrame); } // On Qt4 + macOS with unifiedTitleAndToolBarOnMac set it's possible to make diff --git a/ui/qt/widgets/drag_drop_toolbar.cpp b/ui/qt/widgets/drag_drop_toolbar.cpp index abad03c686..a133222c7d 100644 --- a/ui/qt/widgets/drag_drop_toolbar.cpp +++ b/ui/qt/widgets/drag_drop_toolbar.cpp @@ -86,6 +86,12 @@ void DragDropToolBar::childEvent(QChildEvent * event) } } +void DragDropToolBar::clear() +{ + QToolBar::clear(); + childCounter = 0; +} + bool DragDropToolBar::eventFilter(QObject * obj, QEvent * event) { if ( ! obj->isWidgetType() ) @@ -108,6 +114,11 @@ bool DragDropToolBar::eventFilter(QObject * obj, QEvent * event) if ( ( ev->buttons() & Qt::LeftButton ) && (ev->pos() - dragStartPosition).manhattanLength() > QApplication::startDragDistance()) { + bool success = false; + int element = elem->property(drag_drop_toolbar_action_).toInt(&success); + if ( ! success ) + return false; + ToolbarEntryMimeData * temd = new ToolbarEntryMimeData(((QToolButton *)elem)->text(), elem->property(drag_drop_toolbar_action_).toInt()); DragLabel * lbl = new DragLabel(temd->labelText(), this); @@ -154,14 +165,6 @@ void DragDropToolBar::dragEnterEvent(QDragEnterEvent *event) } else { event->acceptProposedAction(); } - } else if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) { - if ( event->source() != this ) - { - event->setDropAction(Qt::CopyAction); - event->accept(); - } else { - event->acceptProposedAction(); - } } else { event->ignore(); } @@ -174,6 +177,22 @@ void DragDropToolBar::dragMoveEvent(QDragMoveEvent *event) if (qobject_cast<const ToolbarEntryMimeData *>(event->mimeData())) { + QAction * actionAtPos = actionAt(event->pos() ); + if ( actionAtPos ) + { + QWidget * widget = widgetForAction(actionAtPos); + if ( widget ) + { + bool success = false; + widget->property(drag_drop_toolbar_action_).toInt(&success); + if ( ! success ) + { + event->ignore(); + return; + } + } + } + if (event->source() == this) { event->setDropAction(Qt::MoveAction); event->accept(); @@ -211,7 +230,9 @@ void DragDropToolBar::dropEvent(QDropEvent *event) widgetForAction(action)->setStyleSheet("QWidget { border: none; };"); newPos = widgetForAction(action)->property(drag_drop_toolbar_action_).toInt(); moveToolbarItems(oldPos, newPos); - emit actionMoved(actions().at(oldPos), oldPos, newPos); + QAction * moveAction = actions().at(oldPos); + + emit actionMoved(moveAction, oldPos, newPos); } if (event->source() == this) { diff --git a/ui/qt/widgets/drag_drop_toolbar.h b/ui/qt/widgets/drag_drop_toolbar.h index 3958a0ca33..122ba118d5 100644 --- a/ui/qt/widgets/drag_drop_toolbar.h +++ b/ui/qt/widgets/drag_drop_toolbar.h @@ -34,6 +34,8 @@ public: explicit DragDropToolBar(QWidget *parent = Q_NULLPTR); ~DragDropToolBar(); + virtual void clear(); + Q_SIGNALS: void actionMoved(QAction * action, int oldPos, int newPos); |