calamares/src/modules/partition/gui/ChoicePage.h

165 lines
4.8 KiB
C
Raw Normal View History

/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CHOICEPAGE_H
#define CHOICEPAGE_H
2015-09-30 17:24:37 +02:00
#include "ui_ChoicePage.h"
#include <QWidget>
#include "core/OsproberEntry.h"
#include <QMutex>
#include <QPointer>
class QBoxLayout;
2015-11-20 14:49:37 +01:00
class QComboBox;
class QLabel;
class QListView;
class PartitionBarsView;
class PartitionSplitterWidget;
class PartitionLabelsView;
class PartitionCoreModule;
class PrettyRadioButton;
2015-11-27 17:25:47 +01:00
class DeviceInfoWidget;
class Device;
2017-03-03 12:32:35 +01:00
/**
* @brief The ChoicePage class is the first page of the partitioning interface.
* It offers a choice between partitioning operations and initiates all automated
* partitioning modes. For manual partitioning, see PartitionPage.
*/
2015-09-30 17:24:37 +02:00
class ChoicePage : public QWidget, private Ui::ChoicePage
{
Q_OBJECT
public:
enum Choice
{
NoChoice,
Alongside,
Erase,
Replace,
Manual
};
explicit ChoicePage( QWidget* parent = nullptr );
virtual ~ChoicePage();
2017-03-03 12:32:35 +01:00
/**
* @brief init runs when the PartitionViewStep and the PartitionCoreModule are
* ready. Sets up the rest of the UI based on os-prober output.
* @param core the PartitionCoreModule pointer.
*/
void init( PartitionCoreModule* core );
2017-03-03 12:32:35 +01:00
/**
* @brief isNextEnabled answers whether the current state of the page is such
* that progressing to the next page should be allowed.
* @return true if next is allowed, otherwise false.
*/
2015-04-15 12:20:01 +02:00
bool isNextEnabled() const;
2017-03-03 12:32:35 +01:00
/**
* @brief currentChoice returns the enum Choice value corresponding to the
* currently selected partitioning mode (with a PrettyRadioButton).
* @return the enum Choice value.
*/
2015-04-15 12:20:01 +02:00
Choice currentChoice() const;
2017-03-03 12:32:35 +01:00
/**
* @brief onLeave runs when control passes from this page to another one.
*/
void onLeave();
2017-03-03 12:32:35 +01:00
/**
* @brief applyActionChoice reacts to a choice of partitioning mode.
* @param choice the partitioning action choice.
*/
2016-06-29 18:46:02 +02:00
void applyActionChoice( ChoicePage::Choice choice );
signals:
2014-09-04 19:37:30 +02:00
void nextStatusChanged( bool );
void actionChosen();
void deviceChosen();
private slots:
void onPartitionToReplaceSelected( const QModelIndex& current, const QModelIndex& previous );
void doReplaceSelectedPartition( const QModelIndex& current );
2016-01-12 14:04:25 +01:00
void doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous );
void onEncryptWidgetStateChanged();
void onHomeCheckBoxStateChanged();
private:
void updateNextEnabled();
void setupChoices();
QComboBox* createBootloaderComboBox( QWidget* parentButton );
Device* selectedDevice();
/* Change the UI depending on the device selected. */
void hideButtons(); // Hide everything when no device
void applyDeviceChoice(); // Start scanning new device
void continueApplyDeviceChoice(); // .. called after scan
void updateDeviceStatePreview();
void updateActionChoicePreview( ChoicePage::Choice choice );
void setupActions();
OsproberEntryList getOsproberEntriesForDevice( Device* device ) const;
void doAlongsideApply();
2016-02-19 16:57:49 +01:00
void setupEfiSystemPartitionSelector();
bool m_nextEnabled;
PartitionCoreModule* m_core;
QMutex m_previewsMutex;
Choice m_choice;
bool m_isEfi;
QComboBox* m_drivesCombo;
QButtonGroup* m_grp;
PrettyRadioButton* m_alongsideButton;
PrettyRadioButton* m_eraseButton;
PrettyRadioButton* m_replaceButton;
PrettyRadioButton* m_somethingElseButton;
2015-11-27 17:25:47 +01:00
DeviceInfoWidget* m_deviceInfoWidget;
QPointer< PartitionBarsView > m_beforePartitionBarsView;
QPointer< PartitionLabelsView > m_beforePartitionLabelsView;
QPointer< PartitionBarsView > m_afterPartitionBarsView;
QPointer< PartitionLabelsView > m_afterPartitionLabelsView;
QPointer< PartitionSplitterWidget > m_afterPartitionSplitterWidget;
2016-01-29 17:07:08 +01:00
QPointer< QComboBox > m_bootloaderComboBox;
QPointer< QLabel > m_efiLabel;
QPointer< QComboBox > m_efiComboBox;
int m_lastSelectedDeviceIndex;
QString m_defaultFsType;
2016-09-26 13:14:54 +02:00
bool m_enableEncryptionWidget;
QMutex m_coreMutex;
};
#endif // CHOICEPAGE_H