aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_fomod_plus/installer/ui/FomodImageViewer.h
blob: 73a06f72162cb0153c7d2903059da493ef2c8b0e (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once

#include "FomodViewModel.h"

#include <QDialog>
#include <QKeyEvent>
#include <QLabel>
#include <QScrollArea>

class ScaleLabel;
using LabelImagePair = std::pair<QString, QString>;


/*
+----------------------------------------------------------+
|n/N                                                    X  |
+---+--------------------------------------------------+---+
|   |                                                  |   |
|   |                                                  |   |
|   |                                                  |   |
|   |                                                  |   |
|   |                                                  |   |
|   |                                                  |   |
| < |               Image                              | > |
|   |                                                  |   |
|   |                                                  |   |
|   |                                                  |   |
|   |                                                  |   |
|   |                 label                            |   |
+------+------+------+---------------------------------+---+
|      |      |      |  ...previews                        |
|      |      |      |                                     |
+------+------+------+-------------------------------------+
*/

class FomodImageViewer final : public QDialog {
    Q_OBJECT

public:
    explicit FomodImageViewer(QWidget* parent,
        const QString& fomodPath,
        const std::shared_ptr<StepViewModel>& activeStep,
        const std::shared_ptr<PluginViewModel>& activePlugin);

private:
    void collectImages();

    QWidget* createCenterRow(QWidget* parent);

    QWidget* createSinglePhotoPane(QWidget* parent);

    QScrollArea* createPreviewImages(QWidget* parent);

    QPushButton* createBackButton(QWidget* parent) const;

    QPushButton* createForwardButton(QWidget* parent) const;

    QWidget* createTopBar(QWidget* parent);

    QPushButton* createCloseButton(QWidget* parent);

    void updateCounterText() const;

    void goBack();

    void goForward();

    void select(int index);

    void keyPressEvent(QKeyEvent* event) override;

    void showEvent(QShowEvent* event) override;

    std::vector<LabelImagePair> mLabelsAndImages;
    std::vector<QWidget*> mImagePanes{};
    int mCurrentIndex{ 0 };

    QString mFomodPath;
    const std::shared_ptr<StepViewModel>& mActiveStep;
    const std::shared_ptr<PluginViewModel>& mActivePlugin;

    QWidget* mCenterRow{ nullptr };
    QWidget* mTopBar{ nullptr };
    QWidget* mCloseButton{ nullptr };
    QPushButton* mBackButton{ nullptr };
    QPushButton* mForwardButton{ nullptr };
    QLabel* mCounter{ nullptr };
    QWidget* mMainImageWrapper{ nullptr };
    ScaleLabel* mMainImage{ nullptr };
    QLabel* mLabel{ nullptr };
    QScrollArea* mPreviewImages{ nullptr };
};