diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2016-02-02 09:10:54 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2016-02-03 07:54:02 +0000 |
commit | 5646480f27007789429c7e813423c7f142810cc3 (patch) | |
tree | 29452400aa66e2dc8b17f4ef643128aff25ba8ce /src/plugins/coreplugin/progressmanager | |
parent | 7a9cc3499e81185ec24ce383cefc0f6e43f00ce4 (diff) | |
download | qt-creator-5646480f27007789429c7e813423c7f142810cc3.tar.gz |
Core: Use Qt5-style connects
The heavy lifting was done by clazy.
Change-Id: I2dde14919d917816d02117338205f8f861d8af0a
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/plugins/coreplugin/progressmanager')
4 files changed, 48 insertions, 46 deletions
diff --git a/src/plugins/coreplugin/progressmanager/futureprogress.cpp b/src/plugins/coreplugin/progressmanager/futureprogress.cpp index 9c499a34a4..e06451eac6 100644 --- a/src/plugins/coreplugin/progressmanager/futureprogress.cpp +++ b/src/plugins/coreplugin/progressmanager/futureprogress.cpp @@ -54,12 +54,10 @@ class FutureProgressPrivate : public QObject { Q_OBJECT -public slots: - void fadeAway(); - public: explicit FutureProgressPrivate(FutureProgress *q); + void fadeAway(); void tryToFadeAway(); QFutureWatcher<void> m_watcher; @@ -135,14 +133,16 @@ FutureProgress::FutureProgress(QWidget *parent) : d->m_widgetLayout->setContentsMargins(7, 0, 7, 2); d->m_widgetLayout->setSpacing(0); - connect(&d->m_watcher, SIGNAL(started()), this, SLOT(setStarted())); - connect(&d->m_watcher, SIGNAL(finished()), this, SLOT(setFinished())); - connect(&d->m_watcher, SIGNAL(canceled()), this, SIGNAL(canceled())); - connect(&d->m_watcher, SIGNAL(progressRangeChanged(int,int)), this, SLOT(setProgressRange(int,int))); - connect(&d->m_watcher, SIGNAL(progressValueChanged(int)), this, SLOT(setProgressValue(int))); - connect(&d->m_watcher, SIGNAL(progressTextChanged(QString)), - this, SLOT(setProgressText(QString))); - connect(d->m_progress, SIGNAL(clicked()), this, SLOT(cancel())); + connect(&d->m_watcher, &QFutureWatcherBase::started, this, &FutureProgress::setStarted); + connect(&d->m_watcher, &QFutureWatcherBase::finished, this, &FutureProgress::setFinished); + connect(&d->m_watcher, &QFutureWatcherBase::canceled, this, &FutureProgress::canceled); + connect(&d->m_watcher, &QFutureWatcherBase::progressRangeChanged, + this, &FutureProgress::setProgressRange); + connect(&d->m_watcher, &QFutureWatcherBase::progressValueChanged, + this, &FutureProgress::setProgressValue); + connect(&d->m_watcher, &QFutureWatcherBase::progressTextChanged, + this, &FutureProgress::setProgressText); + connect(d->m_progress, &Internal::ProgressBar::clicked, this, &FutureProgress::cancel); setMinimumWidth(100); setMaximumWidth(300); } @@ -212,7 +212,7 @@ bool FutureProgress::eventFilter(QObject *, QEvent *e) if (d->m_keep != KeepOnFinish && d->m_waitingForUserInteraction && (e->type() == QEvent::MouseMove || e->type() == QEvent::KeyPress)) { qApp->removeEventFilter(this); - QTimer::singleShot(notificationTimeout, d, SLOT(fadeAway())); + QTimer::singleShot(notificationTimeout, d, &FutureProgressPrivate::fadeAway); } return false; } @@ -245,7 +245,7 @@ void FutureProgressPrivate::tryToFadeAway() qApp->installEventFilter(m_q); m_fadeStarting = true; } else if (m_keep == FutureProgress::HideOnFinish) { - QTimer::singleShot(shortNotificationTimeout, this, SLOT(fadeAway())); + QTimer::singleShot(shortNotificationTimeout, this, &FutureProgressPrivate::fadeAway); m_fadeStarting = true; } } @@ -386,7 +386,7 @@ void FutureProgressPrivate::fadeAway() animation->setEndValue(0.0); group->addAnimation(animation); - connect(group, SIGNAL(finished()), m_q, SIGNAL(removeMe())); + connect(group, &QAbstractAnimation::finished, m_q, &FutureProgress::removeMe); group->start(QAbstractAnimation::DeleteWhenStopped); emit m_q->fadeStarted(); } diff --git a/src/plugins/coreplugin/progressmanager/futureprogress.h b/src/plugins/coreplugin/progressmanager/futureprogress.h index 945f160a74..6647103009 100644 --- a/src/plugins/coreplugin/progressmanager/futureprogress.h +++ b/src/plugins/coreplugin/progressmanager/futureprogress.h @@ -89,7 +89,7 @@ protected: void mousePressEvent(QMouseEvent *event); void paintEvent(QPaintEvent *); -private slots: +private: void updateToolTip(const QString &); void cancel(); void setStarted(); @@ -98,8 +98,6 @@ private slots: void setProgressValue(int val); void setProgressText(const QString &text); -private: - friend class FutureProgressPrivate; // for sending signal FutureProgressPrivate *d; }; diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index e6a08615cd..1b9c1f6fe5 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -275,8 +275,8 @@ ProgressManagerPrivate::ProgressManagerPrivate() m_instance = this; m_progressView = new ProgressView; // withDelay, so the statusBarWidget has the chance to get the enter event - connect(m_progressView, SIGNAL(hoveredChanged(bool)), this, SLOT(updateVisibilityWithDelay())); - connect(ICore::instance(), SIGNAL(coreAboutToClose()), this, SLOT(cancelAllRunningTasks())); + connect(m_progressView.data(), &ProgressView::hoveredChanged, this, &ProgressManagerPrivate::updateVisibilityWithDelay); + connect(ICore::instance(), &ICore::coreAboutToClose, this, &ProgressManagerPrivate::cancelAllRunningTasks); } ProgressManagerPrivate::~ProgressManagerPrivate() @@ -341,7 +341,8 @@ void ProgressManagerPrivate::init() cmd->setDefaultKeySequence(QKeySequence(HostOsInfo::isMacHost() ? tr("Ctrl+Shift+0") : tr("Alt+Shift+0"))); - connect(toggleProgressView, SIGNAL(toggled(bool)), this, SLOT(progressDetailsToggled(bool))); + connect(toggleProgressView, &QAction::toggled, + this, &ProgressManagerPrivate::progressDetailsToggled); toggleButton->setDefaultAction(cmd->action()); m_progressView->setVisible(m_progressViewPinned); @@ -359,7 +360,7 @@ void ProgressManagerPrivate::doCancelTasks(Id type) continue; } found = true; - disconnect(task.key(), SIGNAL(finished()), this, SLOT(taskFinished())); + disconnect(task.key(), &QFutureWatcherBase::finished, this, &ProgressManagerPrivate::taskFinished); if (m_applicationTask == task.key()) disconnectApplicationTask(); task.key()->cancel(); @@ -390,7 +391,7 @@ bool ProgressManagerPrivate::eventFilter(QObject *obj, QEvent *event) progress = m_taskList.last(); // don't send signal directly from an event filter, event filters should // do as little a possible - QTimer::singleShot(0, progress, SIGNAL(clicked())); + QTimer::singleShot(0, progress, &FutureProgress::clicked); event->accept(); return true; } @@ -402,7 +403,7 @@ void ProgressManagerPrivate::cancelAllRunningTasks() { QMap<QFutureWatcher<void> *, Id>::const_iterator task = m_runningTasks.constBegin(); while (task != m_runningTasks.constEnd()) { - disconnect(task.key(), SIGNAL(finished()), this, SLOT(taskFinished())); + disconnect(task.key(), &QFutureWatcherBase::finished, this, &ProgressManagerPrivate::taskFinished); if (m_applicationTask == task.key()) disconnectApplicationTask(); task.key()->cancel(); @@ -419,9 +420,11 @@ FutureProgress *ProgressManagerPrivate::doAddTask(const QFuture<void> &future, c // watch QFutureWatcher<void> *watcher = new QFutureWatcher<void>(); m_runningTasks.insert(watcher, type); - connect(watcher, SIGNAL(progressRangeChanged(int,int)), this, SLOT(updateSummaryProgressBar())); - connect(watcher, SIGNAL(progressValueChanged(int)), this, SLOT(updateSummaryProgressBar())); - connect(watcher, SIGNAL(finished()), this, SLOT(taskFinished())); + connect(watcher, &QFutureWatcherBase::progressRangeChanged, + this, &ProgressManagerPrivate::updateSummaryProgressBar); + connect(watcher, &QFutureWatcherBase::progressValueChanged, + this, &ProgressManagerPrivate::updateSummaryProgressBar); + connect(watcher, &QFutureWatcherBase::finished, this, &ProgressManagerPrivate::taskFinished); watcher->setFuture(future); // handle application task @@ -431,10 +434,10 @@ FutureProgress *ProgressManagerPrivate::doAddTask(const QFuture<void> &future, c m_applicationTask = watcher; setApplicationProgressRange(future.progressMinimum(), future.progressMaximum()); setApplicationProgressValue(future.progressValue()); - connect(m_applicationTask, SIGNAL(progressRangeChanged(int,int)), - this, SLOT(setApplicationProgressRange(int,int))); - connect(m_applicationTask, SIGNAL(progressValueChanged(int)), - this, SLOT(setApplicationProgressValue(int))); + connect(m_applicationTask, &QFutureWatcherBase::progressRangeChanged, + this, &ProgressManagerPrivate::setApplicationProgressRange); + connect(m_applicationTask, &QFutureWatcherBase::progressValueChanged, + this, &ProgressManagerPrivate::setApplicationProgressValue); setApplicationProgressVisible(true); } @@ -453,10 +456,13 @@ FutureProgress *ProgressManagerPrivate::doAddTask(const QFuture<void> &future, c progress->setKeepOnFinish(FutureProgress::KeepOnFinishTillUserInteraction); else progress->setKeepOnFinish(FutureProgress::HideOnFinish); - connect(progress, SIGNAL(hasErrorChanged()), this, SLOT(updateSummaryProgressBar())); - connect(progress, SIGNAL(removeMe()), this, SLOT(slotRemoveTask())); - connect(progress, SIGNAL(fadeStarted()), this, SLOT(updateSummaryProgressBar())); - connect(progress, SIGNAL(statusBarWidgetChanged()), this, SLOT(updateStatusDetailsWidget())); + connect(progress, &FutureProgress::hasErrorChanged, + this, &ProgressManagerPrivate::updateSummaryProgressBar); + connect(progress, &FutureProgress::removeMe, this, &ProgressManagerPrivate::slotRemoveTask); + connect(progress, &FutureProgress::fadeStarted, + this, &ProgressManagerPrivate::updateSummaryProgressBar); + connect(progress, &FutureProgress::statusBarWidgetChanged, + this, &ProgressManagerPrivate::updateStatusDetailsWidget); updateStatusDetailsWidget(); emit taskStarted(type); @@ -486,10 +492,10 @@ void ProgressManagerPrivate::taskFinished() void ProgressManagerPrivate::disconnectApplicationTask() { - disconnect(m_applicationTask, SIGNAL(progressRangeChanged(int,int)), - this, SLOT(setApplicationProgressRange(int,int))); - disconnect(m_applicationTask, SIGNAL(progressValueChanged(int)), - this, SLOT(setApplicationProgressValue(int))); + disconnect(m_applicationTask, &QFutureWatcherBase::progressRangeChanged, + this, &ProgressManagerPrivate::setApplicationProgressRange); + disconnect(m_applicationTask, &QFutureWatcherBase::progressValueChanged, + this, &ProgressManagerPrivate::setApplicationProgressValue); setApplicationProgressVisible(false); m_applicationTask = 0; } @@ -529,7 +535,7 @@ void ProgressManagerPrivate::fadeAwaySummaryProgress() m_opacityAnimation = new QPropertyAnimation(m_opacityEffect, "opacity"); m_opacityAnimation->setDuration(StyleHelper::progressFadeAnimationDuration); m_opacityAnimation->setEndValue(0.); - connect(m_opacityAnimation, SIGNAL(finished()), this, SLOT(summaryProgressFinishedFading())); + connect(m_opacityAnimation.data(), &QAbstractAnimation::finished, this, &ProgressManagerPrivate::summaryProgressFinishedFading); m_opacityAnimation->start(QAbstractAnimation::DeleteWhenStopped); } @@ -647,7 +653,7 @@ void ProgressManagerPrivate::updateVisibility() void ProgressManagerPrivate::updateVisibilityWithDelay() { - QTimer::singleShot(150, this, SLOT(updateVisibility())); + QTimer::singleShot(150, this, &ProgressManagerPrivate::updateVisibility); } void ProgressManagerPrivate::updateStatusDetailsWidget() @@ -787,8 +793,8 @@ ProgressTimer::ProgressTimer(QObject *parent, m_futureInterface.setProgressValue(0); setInterval(1000); // 1 second - connect(this, SIGNAL(timeout()), this, SLOT(handleTimeout())); - connect(&m_futureWatcher, SIGNAL(started()), this, SLOT(start())); + connect(this, &QTimer::timeout, this, &ProgressTimer::handleTimeout); + connect(&m_futureWatcher, &QFutureWatcherBase::started, this, [this]() { start(); }); } void ProgressTimer::handleTimeout() diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_p.h b/src/plugins/coreplugin/progressmanager/progressmanager_p.h index 1730c3ad97..5603bd750d 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_p.h +++ b/src/plugins/coreplugin/progressmanager/progressmanager_p.h @@ -67,7 +67,7 @@ public slots: protected: bool eventFilter(QObject *obj, QEvent *event); -private slots: +private: void taskFinished(); void cancelAllRunningTasks(); void setApplicationProgressRange(int min, int max); @@ -83,7 +83,6 @@ private slots: void updateStatusDetailsWidget(); void slotRemoveTask(); -private: void readSettings(); void initInternal(); void stopFadeOfSummaryProgress(); @@ -130,10 +129,9 @@ class ProgressTimer : public QTimer public: ProgressTimer(QObject *parent, const QFutureInterface<void> &futureInterface, int expectedSeconds); -private slots: +private: void handleTimeout(); -private: QFutureInterface<void> m_futureInterface; QFutureWatcher<void> m_futureWatcher; int m_expectedTime; |