KDE/kdelibs/kdeui/jobs
Rafael Fernández López
ereslibre at kde.org
Wed Nov 28 18:08:21 GMT 2007
SVN commit 742709 by ereslibre:
The widgetjobtracker now waits 500 ms before being shown. If the job is unregistered before those 500 ms finishes, the dialog is never shown. This is the default behavior
on KDE 3.
CCMAIL: kde-core-devel at kde.org
M +21 -4 kwidgetjobtracker.cpp
M +2 -0 kwidgetjobtracker.h
M +11 -2 kwidgetjobtracker_p.h
--- trunk/KDE/kdelibs/kdeui/jobs/kwidgetjobtracker.cpp #742708:742709
@@ -23,7 +23,7 @@
#include "kwidgetjobtracker_p.h"
#include <QProcess>
-#include <QTime>
+#include <QTimer>
#include <QLabel>
#include <QCheckBox>
#include <QProgressBar>
@@ -41,9 +41,25 @@
#include <klocale.h>
#include <kwindowsystem.h>
+void KWidgetJobTracker::Private::_k_slotShowProgressWidget()
+{
+ if (progressWidgetsToBeShown.isEmpty()) {
+ return;
+ }
+ KJob *job = progressWidgetsToBeShown.dequeue();
+
+ // If the job has been unregistered before reaching this point, widget will
+ // return 0.
+ QWidget *widget = q->widget(job);
+
+ if (widget) {
+ widget->show();
+ }
+}
+
KWidgetJobTracker::KWidgetJobTracker(QWidget *parent)
- : KAbstractWidgetJobTracker(parent), d(new Private(parent))
+ : KAbstractWidgetJobTracker(parent), d(new Private(parent, this))
{
}
@@ -70,9 +86,10 @@
}
Private::ProgressWidget *vi = new Private::ProgressWidget(job, this, d->parent);
- vi->show();
+ d->progressWidget.insert(job, vi);
+ d->progressWidgetsToBeShown.enqueue(job);
- d->progressWidget.insert(job, vi);
+ QTimer::singleShot(500, this, SLOT(_k_slotShowProgressWidget()));
}
void KWidgetJobTracker::unregisterJob(KJob *job)
--- trunk/KDE/kdelibs/kdeui/jobs/kwidgetjobtracker.h #742708:742709
@@ -89,6 +89,8 @@
private:
class Private;
Private *const d;
+
+ Q_PRIVATE_SLOT(d, void _k_slotShowProgressWidget())
};
#endif
--- trunk/KDE/kdelibs/kdeui/jobs/kwidgetjobtracker_p.h #742708:742709
@@ -24,6 +24,7 @@
#include <QWidget>
#include <QMap>
#include <QTime>
+#include <QQueue>
#include <kdebug.h>
#include <kurl.h>
@@ -38,16 +39,23 @@
class KWidgetJobTracker::Private
{
public:
- Private(QWidget *parent)
- : parent(parent) { }
+ Private(QWidget *parent, KWidgetJobTracker *tracker)
+ : parent(parent)
+ , q(tracker)
+ {
+ }
~Private() {
}
+ void _k_slotShowProgressWidget();
+
class ProgressWidget;
QWidget *parent;
+ KWidgetJobTracker *q;
QMap<KJob*, ProgressWidget*> progressWidget;
+ QQueue<KJob*> progressWidgetsToBeShown;
};
@@ -71,6 +79,7 @@
~ProgressWidget()
{
+ q->d->progressWidget.remove(job);
}
KWidgetJobTracker *const q;
More information about the kde-core-devel
mailing list