Changeset View
Changeset View
Standalone View
Standalone View
krusader/Dialogs/krpleasewait.cpp
Show All 31 Lines | |||||
32 | #include <QLabel> | 32 | #include <QLabel> | ||
33 | #include <QProgressBar> | 33 | #include <QProgressBar> | ||
34 | 34 | | |||
35 | #include <KI18n/KLocalizedString> | 35 | #include <KI18n/KLocalizedString> | ||
36 | #include <KWidgetsAddons/KCursor> | 36 | #include <KWidgetsAddons/KCursor> | ||
37 | 37 | | |||
38 | #include "../krglobal.h" | 38 | #include "../krglobal.h" | ||
39 | 39 | | |||
40 | KRPleaseWait::KRPleaseWait(QString msg, QWidget *parent, int count, bool cancel): | 40 | KRPleaseWait::KRPleaseWait(const QString& msg, QWidget *parent, int count, bool cancel): | ||
41 | QProgressDialog(cancel ? 0 : parent) , inc(true) | 41 | QProgressDialog(cancel ? nullptr : parent) , inc(true) | ||
42 | { | 42 | { | ||
43 | setModal(!cancel); | 43 | setModal(!cancel); | ||
44 | 44 | | |||
45 | timer = new QTimer(this); | 45 | timer = new QTimer(this); | ||
46 | setWindowTitle(i18n("Krusader::Wait")); | 46 | setWindowTitle(i18n("Krusader::Wait")); | ||
47 | 47 | | |||
48 | setMinimumDuration(500); | 48 | setMinimumDuration(500); | ||
49 | setAutoClose(false); | 49 | setAutoClose(false); | ||
50 | setAutoReset(false); | 50 | setAutoReset(false); | ||
51 | 51 | | |||
52 | connect(timer, SIGNAL(timeout()), this, SLOT(cycleProgress())); | 52 | connect(timer, SIGNAL(timeout()), this, SLOT(cycleProgress())); | ||
53 | 53 | | |||
54 | QProgressBar* progress = new QProgressBar(this); | 54 | auto* progress = new QProgressBar(this); | ||
55 | progress->setMaximum(count); | 55 | progress->setMaximum(count); | ||
56 | progress->setMinimum(0); | 56 | progress->setMinimum(0); | ||
57 | setBar(progress); | 57 | setBar(progress); | ||
58 | 58 | | |||
59 | QLabel* label = new QLabel(this); | 59 | QLabel* label = new QLabel(this); | ||
60 | setLabel(label); | 60 | setLabel(label); | ||
61 | 61 | | |||
62 | QPushButton* btn = new QPushButton(i18n("&Cancel"), this); | 62 | QPushButton* btn = new QPushButton(i18n("&Cancel"), this); | ||
Show All 23 Lines | |||||
86 | { | 86 | { | ||
87 | if (inc) setValue(value() + 1); | 87 | if (inc) setValue(value() + 1); | ||
88 | else setValue(value() - 1); | 88 | else setValue(value() - 1); | ||
89 | if (value() >= 9) inc = false; | 89 | if (value() >= 9) inc = false; | ||
90 | if (value() <= 0) inc = true; | 90 | if (value() <= 0) inc = true; | ||
91 | } | 91 | } | ||
92 | 92 | | |||
93 | KRPleaseWaitHandler::KRPleaseWaitHandler(QWidget *parentWindow) | 93 | KRPleaseWaitHandler::KRPleaseWaitHandler(QWidget *parentWindow) | ||
94 | : QObject(parentWindow), _parentWindow(parentWindow), job(), dlg(0) | 94 | : QObject(parentWindow), _parentWindow(parentWindow), dlg(nullptr) | ||
95 | { | 95 | { | ||
96 | } | 96 | } | ||
97 | 97 | | |||
98 | void KRPleaseWaitHandler::stopWait() | 98 | void KRPleaseWaitHandler::stopWait() | ||
99 | { | 99 | { | ||
100 | if (dlg != 0) delete dlg; | 100 | if (dlg != nullptr) delete dlg; | ||
101 | dlg = 0; | 101 | dlg = nullptr; | ||
102 | cycleMutex = incMutex = false; | 102 | cycleMutex = incMutex = false; | ||
103 | // return cursor to normal arrow | 103 | // return cursor to normal arrow | ||
104 | _parentWindow->setCursor(Qt::ArrowCursor); | 104 | _parentWindow->setCursor(Qt::ArrowCursor); | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | 107 | | |||
108 | void KRPleaseWaitHandler::startWaiting(QString msg, int count , bool cancel) | 108 | void KRPleaseWaitHandler::startWaiting(const QString& msg, int count , bool cancel) | ||
109 | { | 109 | { | ||
110 | if (dlg == 0) { | 110 | if (dlg == nullptr) { | ||
111 | dlg = new KRPleaseWait(msg , _parentWindow, count, cancel); | 111 | dlg = new KRPleaseWait(msg , _parentWindow, count, cancel); | ||
112 | connect(dlg, SIGNAL(canceled()), this, SLOT(killJob())); | 112 | connect(dlg, SIGNAL(canceled()), this, SLOT(killJob())); | ||
113 | } | 113 | } | ||
114 | incMutex = cycleMutex = _wasCancelled = false; | 114 | incMutex = cycleMutex = _wasCancelled = false; | ||
115 | dlg->setValue(0); | 115 | dlg->setValue(0); | ||
116 | 116 | | |||
117 | dlg->setLabelText(msg); | 117 | dlg->setLabelText(msg); | ||
118 | if (count == 0) { | 118 | if (count == 0) { | ||
Show All 38 Lines |