[kdevplatform/5.0] shell/progresswidget: Fix detailed progress dialog visual glitches

Kevin Funk kfunk at kde.org
Mon Nov 30 16:23:55 UTC 2015


On Tuesday, November 10, 2015 04:53:17 PM Milian Wolff wrote:
> Git commit fa74951345d2c686645e72614ee192c2636140d4 by Milian Wolff, on
> behalf of Maciej Cencora. Committed on 10/11/2015 at 16:51.
> Pushed by mwolff into branch '5.0'.
> 
> Fix detailed progress dialog visual glitches
> 
> Before, the ProgressDialog widget was hidden under any toolview, but not by
> the editor widget or any of IdealToolBar widgets. I have been unable to
> track down why it doesn't work with current setup design: According to
> GammaRay both a toolview (e.g. "Problems", "Find/Replace in Files") and
> ProgressDialog are children of MainWindow widget, but still even manually
> raising and lowering from within GammaRay didn't fix Z-order.
> 
> The workaround "hide the tool view, and activate it again (while the
> detailed progress widget is shown)" actually works only for first frame,
> then the part of ProgressDialog overlapping with tool view widget does not
> update anymore.
> 
> I fixed this by converting the OverlayWidget to a popup widget (just like
> ActiveToolTip).
> 
> Also while there, I fixed removal of separator line between progress items -
> depending on the Qt specific behavior as mentioned in removed comment
> doesn't seem to work out (anymore?).
> 
> REVIEW: 125929

There are some issues with this patch.

Right now my Yakuake window is closed whenever the progress bar hides itself  
after some time.

Steps to reproduce:
- Open some file in KDevelop
- Press F5
- Immediately open Yakuake window (via F12)
- Wait for the background parser process to finish
- Watch Yakuake closing itself when the progress bar is hidden

Note: Works fine with this patch reverted.

@Maciej: Care to have a look at this?

Cheers,
Kevin

> >From ffce9fc57efb10b03d6b21e4fcbff40607e072d6 Mon Sep 17 00:00:00 2001
> 
> From: Maciej Cencora <m.cencora at gmail.com>
> Date: Tue, 3 Nov 2015 10:45:29 +0100
> Subject: [PATCH] Fix detailed progress dialog visual glitches
> 
> M  +13   -14   shell/progresswidget/overlaywidget.cpp
> M  +16   -24   shell/progresswidget/progressdialog.cpp
> M  +1    -1    shell/progresswidget/progressdialog.h
> 
> http://commits.kde.org/kdevplatform/fa74951345d2c686645e72614ee192c2636140d4
> 
> diff --git a/shell/progresswidget/overlaywidget.cpp
> b/shell/progresswidget/overlaywidget.cpp index 6961b14..f3eb998 100644
> --- a/shell/progresswidget/overlaywidget.cpp
> +++ b/shell/progresswidget/overlaywidget.cpp
> @@ -33,17 +33,22 @@
>  #include <QHBoxLayout>
>  #include <QResizeEvent>
>  #include <QEvent>
> +#include <QApplication>
> 
>  using namespace KDevelop;
> 
>  OverlayWidget::OverlayWidget( QWidget* alignWidget, QWidget* parent, const
> char* name ) -    : QWidget( parent ), mAlignWidget( 0 )
> +    : QWidget( parent, Qt::Window | Qt::FramelessWindowHint ),
> mAlignWidget( 0 ) {
>      auto hboxHBoxLayout = new QHBoxLayout(this);
>      hboxHBoxLayout->setMargin(0);
> 
>      setObjectName(name);
>      setAlignWidget( alignWidget );
> +
> +    setWindowFlags(Qt::WindowDoesNotAcceptFocus | windowFlags());
> +
> +    qApp->installEventFilter(this);
>  }
> 
>  OverlayWidget::~OverlayWidget()
> @@ -59,12 +64,10 @@ void OverlayWidget::reposition()
>      // We are always above the alignWidget, right-aligned with it.
>      p.setX( mAlignWidget->width() - width() );
>      p.setY( -height() );
> -    // Position in the toplevelwidget's coordinates
> -    QPoint pTopLevel = mAlignWidget->mapTo( topLevelWidget(), p );
> -    // Position in the widget's parentWidget coordinates
> -    QPoint pParent = parentWidget()->mapFrom( topLevelWidget(), pTopLevel
> ); +    // Position in the global coordinates
> +    QPoint global = mAlignWidget->mapToGlobal( p );
>      // Move 'this' to that position.
> -    move( pParent );
> +    move( global );
>  }
> 
>  void OverlayWidget::setAlignWidget( QWidget * w )
> @@ -72,23 +75,19 @@ void OverlayWidget::setAlignWidget( QWidget * w )
>      if (w == mAlignWidget)
>          return;
> 
> -    if (mAlignWidget)
> -        mAlignWidget->removeEventFilter(this);
> -
>      mAlignWidget = w;
> 
> -    if (mAlignWidget)
> -        mAlignWidget->installEventFilter(this);
> -
>      reposition();
>  }
> 
>  bool OverlayWidget::eventFilter( QObject* o, QEvent* e)
>  {
> -    if ( o == mAlignWidget &&
> -         ( e->type() == QEvent::Move || e->type() == QEvent::Resize ) ) {
> +    if (e->type() == QEvent::Move || e->type() == QEvent::Resize) {
>          reposition();
> +    } else if (e->type() == QEvent::Close) {
> +        close();
>      }
> +
>      return QWidget::eventFilter(o,e);
>  }
> 
> diff --git a/shell/progresswidget/progressdialog.cpp
> b/shell/progresswidget/progressdialog.cpp index a9d048a..2cda081 100644
> --- a/shell/progresswidget/progressdialog.cpp
> +++ b/shell/progresswidget/progressdialog.cpp
> @@ -66,7 +66,7 @@ TransactionItemView::TransactionItemView( QWidget *parent,
> const char *name ) layout->setMargin(0);
>      setWidget( mBigBox );
>      setWidgetResizable( true );
> -    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
> +    setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
>  }
> 
>  TransactionItem *TransactionItemView::addTransactionItem( ProgressItem
> *item, bool first ) @@ -106,34 +106,29 @@ QSize
> TransactionItemView::minimumSizeHint() const int f = 2 * frameWidth();
>      // Make room for a vertical scrollbar in all cases, to avoid a
> horizontal one int vsbExt = verticalScrollBar()->sizeHint().width();
> -    int minw = topLevelWidget()->width() / 3;
> -    int maxh = topLevelWidget()->height() / 2;
>      QSize sz( mBigBox->minimumSizeHint() );
> -    sz.setWidth( qMax( sz.width(), minw ) + f + vsbExt );
> -    sz.setHeight( qMin( sz.height(), maxh ) + f );
> +    sz.setWidth( sz.width() + f + vsbExt );
> +    sz.setHeight( sz.height() + f );
>      return sz;
>  }
> 
> -void TransactionItemView::slotLayoutFirstItem()
> +void TransactionItemView::slotItemCompleted(TransactionItem* item)
>  {
> +    // If completed item is the first, hide separator line for the one that
> will become first now +    if (mBigBox->layout()->indexOf(item) == 0) {
> +        auto *secondItem = mBigBox->layout()->itemAt(1);
> +        if (secondItem) {
> +            static_cast<TransactionItem
> *>(secondItem->widget())->hideHLine(); +        }
> +    }
> +
> +    mBigBox->layout()->removeWidget(item);
> +    delete item;
> +
>      //This slot is called whenever a TransactionItem is deleted, so this is
> a //good place to call updateGeometry(), so our parent takes the new size
> //into account and resizes.
>      updateGeometry();
> -
> -    /*
> -     The below relies on some details in Qt's behaviour regarding deleting
> -     objects. This slot is called from the destroyed signal of an item just
> -     going away. That item is at that point still in the  list of chilren,
> but -     since the vtable is already gone, it will have type QObject. The
> first -     one with both the right name and the right class therefor is
> what will -     be the first item very shortly. That's the one we want to
> remove the -     hline for.
> -  */
> -    TransactionItem *ti = mBigBox->findChild<KDevelop::TransactionItem*>(
> "TransactionItem" ); -    if ( ti ) {
> -        ti->hideHLine();
> -    }
>  }
> 
>  //
> ---------------------------------------------------------------------------
> - @@ -323,10 +318,7 @@ void ProgressDialog::slotTransactionCompleted(
> ProgressItem *item ) TransactionItem *ti = mTransactionsToListviewItems[
> item ]; mTransactionsToListviewItems.remove( item );
>          ti->setItemComplete();
> -        QTimer::singleShot( 3000, ti, SLOT(deleteLater()) );
> -        // see the slot for comments as to why that works
> -        connect ( ti, &TransactionItem::destroyed,
> -                  mScrollView, &TransactionItemView::slotLayoutFirstItem );
> +        QTimer::singleShot( 3000, mScrollView, [=] {
> mScrollView->slotItemCompleted(ti); } ); }
>      // This was the last item, hide.
>      if ( mTransactionsToListviewItems.empty() ) {
> diff --git a/shell/progresswidget/progressdialog.h
> b/shell/progresswidget/progressdialog.h index d4ced74..340160f 100644
> --- a/shell/progresswidget/progressdialog.h
> +++ b/shell/progresswidget/progressdialog.h
> @@ -51,7 +51,7 @@ public:
>      QSize minimumSizeHint() const override;
> 
>  public Q_SLOTS:
> -    void slotLayoutFirstItem();
> +    void slotItemCompleted(TransactionItem * item);
> 
>  protected:
>      virtual void resizeEvent ( QResizeEvent *event ) override;

-- 
Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20151130/d1bd4f70/attachment.sig>


More information about the KDevelop-devel mailing list