rename rootfs msg

rename supportedForWriting to canWrite
This commit is contained in:
Dmitry Degtyarev 2020-11-02 16:49:48 +04:00
parent b92267989a
commit ea2ffdf5a8
3 changed files with 12 additions and 44 deletions

View File

@ -113,7 +113,7 @@ Dialog {
}
PropertyChanges {
target: rightButton;
enabled: releases.variant.imageType.supportedForWriting;
enabled: releases.variant.imageType.canWrite;
color: "red";
onClicked: drives.selected.write(releases.variant)
}
@ -344,7 +344,7 @@ Dialog {
}
AdwaitaCheckBox {
text: qsTr("Write the image after downloading")
enabled: drives.selected && ((releases.variant.status == Variant.DOWNLOADING) || (releases.variant.status == Variant.DOWNLOAD_RESUMING)) && releases.variant.imageType.supportedForWriting
enabled: drives.selected && ((releases.variant.status == Variant.DOWNLOADING) || (releases.variant.status == Variant.DOWNLOAD_RESUMING)) && releases.variant.imageType.canWrite
visible: enabled
onCheckedChanged: {
@ -425,8 +425,7 @@ Dialog {
width: 1
}
Text {
// Show this if image type is not supported and can't be rootfs'ed
visible: releases.variant && !releases.variant.imageType.supportedForWriting && !releases.variant.imageType.canWriteWithRootfs
visible: !releases.variant.imageType.canWrite
font.pointSize: 10
Layout.fillWidth: true
width: Layout.width
@ -434,16 +433,6 @@ Dialog {
text: qsTr("Writing this image type is not supported.")
color: "red"
}
Text {
// Show this if image type is not supported BUT can be rootfs'ed
visible: releases.variant && !releases.variant.imageType.supportedForWriting && releases.variant.imageType.canWriteWithRootfs
font.pointSize: 10
Layout.fillWidth: true
width: Layout.width
wrapMode: Text.WordWrap
text: drives.selected ? qsTr("Writing this image type is not supported here but you can write it using rootfs:\nsudo alt-rootfs-installer --rootfs=%1 --media=%2 --target=%3").arg(releases.variant.image).arg(drives.selected.devicePath).arg(releases.variant.board) : qsTr("Writing this image type is not supported here but you can write it using rootfs. Insert a drive to get a formatted command.")
color: "black"
}
RowLayout {
height: rightButton.height
Layout.minimumWidth: parent.width

View File

@ -38,7 +38,6 @@ bool ImageType::isValid() const {
QStringList ImageType::abbreviation() const {
switch (m_id) {
case ISO: return {"iso", "dvd"};
case TAR: return {"tar"};
case TAR_GZ: return {"tgz", "tar.gz"};
case TAR_XZ: return {"archive", "tar.xz"};
case IMG: return {"img"};
@ -54,7 +53,6 @@ QStringList ImageType::abbreviation() const {
QString ImageType::name() const {
switch (m_id) {
case ISO: return tr("ISO DVD");
case TAR: return {"TAR Archive"};
case TAR_GZ: return tr("GZIP TAR Archive");
case TAR_XZ: return tr("LZMA TAR Archive");
case IMG: return tr("IMG");
@ -67,27 +65,16 @@ QString ImageType::name() const {
return QString();
}
bool ImageType::supportedForWriting() const {
static const QList<ImageType::Id> unsupported = {
TAR_GZ, TAR_XZ, IMG_GZ, RECOVERY_TAR, UNKNOWN, COUNT
bool ImageType::canWrite() const {
static const QList<ImageType::Id> supported_types = {
ISO, IMG, IMG_XZ
};
return !unsupported.contains(m_id);
}
bool ImageType::canWriteWithRootfs() const {
#if defined(_WIN32)
return false;
#else
if (m_id == TAR_XZ) {
return true;
} else {
return false;
}
#endif
return supported_types.contains(m_id);
}
ImageType::ImageType(const ImageType::Id id_arg)
: m_id(id_arg) {
: m_id(id_arg)
{
}

View File

@ -25,25 +25,19 @@
#include <QString>
/**
* @brief The ImageType class
*
* Class representing the possible image types of the releases
*
* @property abbreviation short names for the type, like iso
* @property name a common name what the short stands for, like "ISO DVD"
* @property supportedForWriting whether this image type can be written to media
* @property canWriteWithRootfs whether this image type can be written with rootfs
* @property canWrite whether this image type is supported for writing
*/
class ImageType final : public QObject {
Q_OBJECT
Q_PROPERTY(QStringList abbreviation READ abbreviation CONSTANT)
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(bool supportedForWriting READ supportedForWriting CONSTANT)
Q_PROPERTY(bool canWriteWithRootfs READ canWriteWithRootfs CONSTANT)
Q_PROPERTY(bool canWrite READ canWrite CONSTANT)
public:
enum Id {
ISO,
TAR,
TAR_GZ,
TAR_XZ,
IMG,
@ -61,9 +55,7 @@ public:
bool isValid() const;
QStringList abbreviation() const;
QString name() const;
QString description() const;
bool supportedForWriting() const;
bool canWriteWithRootfs() const;
bool canWrite() const;
private:
ImageType(const ImageType::Id id_arg);