source: calamares/trunk/fuentes/src/modules/partition/gui/ChoicePage.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 4.8 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
4 *
5 *   Calamares is free software: you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, either version 3 of the License, or
8 *   (at your option) any later version.
9 *
10 *   Calamares is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef CHOICEPAGE_H
20#define CHOICEPAGE_H
21
22#include "ui_ChoicePage.h"
23
24#include <QWidget>
25
26#include "core/OsproberEntry.h"
27
28#include <QMutex>
29#include <QPointer>
30
31class QBoxLayout;
32class QComboBox;
33class QLabel;
34class QListView;
35
36class PartitionBarsView;
37class PartitionSplitterWidget;
38class PartitionLabelsView;
39class PartitionCoreModule;
40class PrettyRadioButton;
41class DeviceInfoWidget;
42
43class Device;
44
45
46/**
47 * @brief The ChoicePage class is the first page of the partitioning interface.
48 * It offers a choice between partitioning operations and initiates all automated
49 * partitioning modes. For manual partitioning, see PartitionPage.
50 */
51class ChoicePage : public QWidget, private Ui::ChoicePage
52{
53    Q_OBJECT
54public:
55    enum Choice
56    {
57        NoChoice,
58        Alongside,
59        Erase,
60        Replace,
61        Manual
62    };
63
64    explicit ChoicePage( QWidget* parent = nullptr );
65    virtual ~ChoicePage();
66
67    /**
68     * @brief init runs when the PartitionViewStep and the PartitionCoreModule are
69     *      ready. Sets up the rest of the UI based on os-prober output.
70     * @param core the PartitionCoreModule pointer.
71     */
72    void init( PartitionCoreModule* core );
73
74    /**
75     * @brief isNextEnabled answers whether the current state of the page is such
76     * that progressing to the next page should be allowed.
77     * @return true if next is allowed, otherwise false.
78     */
79    bool isNextEnabled() const;
80
81    /**
82     * @brief currentChoice returns the enum Choice value corresponding to the
83     * currently selected partitioning mode (with a PrettyRadioButton).
84     * @return the enum Choice value.
85     */
86    Choice currentChoice() const;
87
88    /**
89     * @brief onLeave runs when control passes from this page to another one.
90     */
91    void onLeave();
92
93    /**
94     * @brief applyActionChoice reacts to a choice of partitioning mode.
95     * @param choice the partitioning action choice.
96     */
97    void applyActionChoice( ChoicePage::Choice choice );
98
99signals:
100    void nextStatusChanged( bool );
101    void actionChosen();
102    void deviceChosen();
103
104private slots:
105    void onPartitionToReplaceSelected( const QModelIndex& current, const QModelIndex& previous );
106    void doReplaceSelectedPartition( const QModelIndex& current );
107    void doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous );
108    void onEncryptWidgetStateChanged();
109    void onHomeCheckBoxStateChanged();
110
111private:
112    void updateNextEnabled();
113    void setupChoices();
114    QComboBox* createBootloaderComboBox( QWidget* parentButton );
115    Device* selectedDevice();
116
117    /* Change the UI depending on the device selected. */
118    void hideButtons();  // Hide everything when no device
119    void applyDeviceChoice();  // Start scanning new device
120    void continueApplyDeviceChoice();  // .. called after scan
121
122    void updateDeviceStatePreview();
123    void updateActionChoicePreview( ChoicePage::Choice choice );
124    void setupActions();
125    OsproberEntryList getOsproberEntriesForDevice( Device* device ) const;
126    void doAlongsideApply();
127    void setupEfiSystemPartitionSelector();
128
129    bool m_nextEnabled;
130    PartitionCoreModule* m_core;
131
132    QMutex m_previewsMutex;
133
134    Choice m_choice;
135
136    bool m_isEfi;
137    QComboBox* m_drivesCombo;
138
139    QButtonGroup* m_grp;
140    PrettyRadioButton* m_alongsideButton;
141    PrettyRadioButton* m_eraseButton;
142    PrettyRadioButton* m_replaceButton;
143    PrettyRadioButton* m_somethingElseButton;
144
145    DeviceInfoWidget* m_deviceInfoWidget;
146
147    QPointer< PartitionBarsView > m_beforePartitionBarsView;
148    QPointer< PartitionLabelsView > m_beforePartitionLabelsView;
149    QPointer< PartitionBarsView > m_afterPartitionBarsView;
150    QPointer< PartitionLabelsView > m_afterPartitionLabelsView;
151    QPointer< PartitionSplitterWidget > m_afterPartitionSplitterWidget;
152    QPointer< QComboBox > m_bootloaderComboBox;
153    QPointer< QLabel > m_efiLabel;
154    QPointer< QComboBox > m_efiComboBox;
155
156    int m_lastSelectedDeviceIndex;
157
158    QString m_defaultFsType;
159    bool m_enableEncryptionWidget;
160
161    QMutex m_coreMutex;
162};
163
164#endif // CHOICEPAGE_H
Note: See TracBrowser for help on using the repository browser.