summaryrefslogtreecommitdiff
path: root/ui/qt5/stepprogresswidget.hh
blob: 07f2979fcc51d4382827d2bd31f80238c871ae26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * stepprogresswidget.hh -
 * Interface for a widget for displaying progress through a series of steps
 * horizon-qt5, the Qt 5 user interface for
 * Project Horizon
 *
 * Copyright (c) 2020 Adélie Linux and contributors.  All rights reserved.
 * This code is licensed under the AGPL 3.0 license, as noted in the
 * LICENSE-code file in the root directory of this repository.
 *
 * SPDX-License-Identifier: AGPL-3.0-only
 */

#ifndef STEPPROGRESSWIDGET_HH
#define STEPPROGRESSWIDGET_HH

#include <QGridLayout>
#include <QLabel>
#include <QWidget>

class StepProgressWidget : public QWidget {
public:
    enum Status {
        NotStarted,
        InProgress,
        Finished,
        Failed
    };

    StepProgressWidget(QWidget *parent = nullptr);

    /*! Returns the current overview text. */
    QString overviewText();
    /*! Sets a custom overview text for the operations being performed. */
    void setOverviewText(QString overview);

    /*! Add a step to this progress widget. */
    int16_t addStep(QString stepInfo);
    /*! Set the status of a step. */
    void setStepStatus(int16_t step, Status status);
    /*! Sets the status of +step+ as Finished, and the following step
     *  InProgress.  This is a short hand for:
     *
     *  setStepStatus(step, Finished);
     *  setStepStatus(step + 1, InProgress);
     */
    void stepPassed(int16_t step);
private:
    /*! The overview text widget */
    QLabel *overview;

    /*! Grid layout with the steps */
    QGridLayout *stepGrid;

    /*! All the step status icons */
    QVector<QLabel *> statuses;
    /*! All the step info labels */
    QVector<QLabel *> infos;

    /*! The fonts used for infos */
    QFont normalFont, boldFont;

    QPixmap loadDPIAwarePixmap(QString pixmap, QString type);
};

#endif /* !STEPPROGRESSWIDGET_HH */