progressmanager_p.h 3.82 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

30 31
#ifndef PROGRESSMANAGER_P_H
#define PROGRESSMANAGER_P_H
con's avatar
con committed
32

33
#include "progressmanager.h"
con's avatar
con committed
34

35
#include <QFutureWatcher>
36 37 38 39 40
#include <QList>
#include <QGraphicsOpacityEffect>
#include <QPointer>
#include <QPropertyAnimation>
#include <QToolButton>
con's avatar
con committed
41 42

namespace Core {
43 44 45

class StatusBarWidget;

con's avatar
con committed
46 47
namespace Internal {

48
class ProgressBar;
con's avatar
con committed
49 50
class ProgressView;

51
class ProgressManagerPrivate : public Core::ProgressManager
con's avatar
con committed
52 53 54
{
    Q_OBJECT
public:
55 56
    ProgressManagerPrivate(QObject *parent = 0);
    ~ProgressManagerPrivate();
con's avatar
con committed
57
    void init();
58
    void cleanup();
con's avatar
con committed
59

60 61
    FutureProgress *addTask(const QFuture<void> &future, const QString &title, const QString &type,
                            ProgressFlags flags);
con's avatar
con committed
62

63
    void setApplicationLabel(const QString &text);
64
    ProgressView *progressView();
con's avatar
con committed
65 66 67 68

public slots:
    void cancelTasks(const QString &type);

69 70 71
protected:
    bool eventFilter(QObject *obj, QEvent *event);

con's avatar
con committed
72 73 74
private slots:
    void taskFinished();
    void cancelAllRunningTasks();
75 76 77 78
    void setApplicationProgressRange(int min, int max);
    void setApplicationProgressValue(int value);
    void setApplicationProgressVisible(bool visible);
    void disconnectApplicationTask();
79
    void updateSummaryProgressBar();
80 81
    void fadeAwaySummaryProgress();
    void summaryProgressFinishedFading();
82 83 84
    void progressDetailsToggled(bool checked);
    void updateVisibility();
    void updateVisibilityWithDelay();
85

86
    void slotRemoveTask();
con's avatar
con committed
87
private:
88
    void initInternal();
89 90 91 92 93 94 95 96 97
    void stopFadeOfSummaryProgress();

    bool hasError() const;
    bool isLastFading() const;

    void removeOldTasks(const QString &type, bool keepOne = false);
    void removeOneOldTask();
    void removeTask(FutureProgress *task);
    void deleteTask(FutureProgress *task);
98

con's avatar
con committed
99
    QPointer<ProgressView> m_progressView;
100
    QList<FutureProgress *> m_taskList;
con's avatar
con committed
101
    QMap<QFutureWatcher<void> *, QString> m_runningTasks;
102
    QFutureWatcher<void> *m_applicationTask;
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    Core::StatusBarWidget *m_statusBarWidgetContainer;
    QWidget *m_statusBarWidget;
    ProgressBar *m_summaryProgressBar;
    QGraphicsOpacityEffect *m_opacityEffect;
    QPointer<QPropertyAnimation> m_opacityAnimation;
    bool m_progressViewPinned;
    bool m_hovered;
};

class ToggleButton : public QToolButton
{
    Q_OBJECT
public:
    ToggleButton(QWidget *parent);
    QSize sizeHint() const;
    void paintEvent(QPaintEvent *event);
con's avatar
con committed
119 120 121 122 123
};

} // namespace Internal
} // namespace Core

124
#endif // PROGRESSMANAGER_P_H