Changeset View
Changeset View
Standalone View
Standalone View
src/statusbar/ProgressBar.h
Show All 19 Lines | |||||
20 | #include "amarok_export.h" | 20 | #include "amarok_export.h" | ||
21 | 21 | | |||
22 | #include <QFrame> | 22 | #include <QFrame> | ||
23 | #include <QHBoxLayout> | 23 | #include <QHBoxLayout> | ||
24 | #include <QLabel> | 24 | #include <QLabel> | ||
25 | #include <QProgressBar> | 25 | #include <QProgressBar> | ||
26 | #include <QToolButton> | 26 | #include <QToolButton> | ||
27 | 27 | | |||
28 | #include <functional> | ||||
29 | | ||||
28 | #define POST_COMPLETION_DELAY 2000 | 30 | #define POST_COMPLETION_DELAY 2000 | ||
29 | 31 | | |||
30 | /** | 32 | /** | ||
31 | * A widget that encapsulates a progress bar, a description string and a cancel button. | 33 | * A widget that encapsulates a progress bar, a description string and a cancel button. | ||
32 | */ | 34 | */ | ||
33 | class AMAROK_EXPORT ProgressBar : public QFrame | 35 | class AMAROK_EXPORT ProgressBar : public QFrame | ||
34 | { | 36 | { | ||
35 | Q_OBJECT | 37 | Q_OBJECT | ||
36 | 38 | | |||
37 | public: | 39 | public: | ||
38 | explicit ProgressBar( QWidget *parent ); | 40 | explicit ProgressBar( QWidget *parent ); | ||
39 | ~ProgressBar(); | 41 | ~ProgressBar(); | ||
40 | 42 | | |||
41 | void setDescription( const QString &description ); | 43 | void setDescription( const QString &description ); | ||
42 | 44 | | |||
43 | ProgressBar *setAbortSlot( QObject *receiver, const char *slot, | 45 | template<class Receiver, class Func> | ||
44 | Qt::ConnectionType type = Qt::AutoConnection ); | 46 | ProgressBar *setAbortSlot( Receiver receiver, Func slot, | ||
45 | template<typename Func> | | |||
46 | ProgressBar *setAbortSlot( const typename QtPrivate::FunctionPointer<Func>::Object *receiver, Func slot, | | |||
47 | Qt::ConnectionType type = Qt::AutoConnection ) | 47 | Qt::ConnectionType type = Qt::AutoConnection ) | ||
48 | { | 48 | { | ||
49 | cancelButton()->setHidden( false ); | 49 | cancelButton()->setHidden( false ); | ||
50 | if( receiver ) | 50 | if( receiver ) | ||
51 | connect( this, &ProgressBar::cancelled, receiver, slot, type ); | 51 | connect( this, &ProgressBar::cancelled, receiver, slot, type ); | ||
52 | connect( cancelButton(), &QAbstractButton::clicked, this, &ProgressBar::cancel ); | 52 | connect( cancelButton(), &QAbstractButton::clicked, this, &ProgressBar::cancel ); | ||
53 | 53 | | |||
54 | return this; | 54 | return this; | ||
Show All 29 Lines |