Improve drive listing
- Show write protected SD cards greyed out. Show message if user select one of those. Closes #59 - Do show virtual drive types on Windows. Do keep them hidden on Mac OS X as that seems to cover .dmg file and timemachine stuff. Closes #79
This commit is contained in:
+2
-2
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "drivelistitem.h"
|
||||
|
||||
DriveListItem::DriveListItem(QString device, QString description, quint64 size, bool isUsb, bool isScsi, QStringList mountpoints, QObject *parent)
|
||||
: QObject(parent), _device(device), _description(description), _mountpoints(mountpoints), _size(size), _isUsb(isUsb), _isScsi(isScsi)
|
||||
DriveListItem::DriveListItem(QString device, QString description, quint64 size, bool isUsb, bool isScsi, bool readOnly, QStringList mountpoints, QObject *parent)
|
||||
: QObject(parent), _device(device), _description(description), _mountpoints(mountpoints), _size(size), _isUsb(isUsb), _isScsi(isScsi), _isReadOnly(readOnly)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -13,7 +13,7 @@ class DriveListItem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DriveListItem(QString device, QString description, quint64 size, bool isUsb = false, bool isScsi = false, QStringList mountpoints = QStringList(), QObject *parent = nullptr);
|
||||
explicit DriveListItem(QString device, QString description, quint64 size, bool isUsb = false, bool isScsi = false, bool readOnly = false, QStringList mountpoints = QStringList(), QObject *parent = nullptr);
|
||||
|
||||
Q_PROPERTY(QString device MEMBER _device CONSTANT)
|
||||
Q_PROPERTY(QString description MEMBER _description CONSTANT)
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
Q_PROPERTY(QStringList mountpoints MEMBER _mountpoints CONSTANT)
|
||||
Q_PROPERTY(bool isUsb MEMBER _isUsb CONSTANT)
|
||||
Q_PROPERTY(bool isScsi MEMBER _isScsi CONSTANT)
|
||||
Q_PROPERTY(bool isReadOnly MEMBER _isReadOnly CONSTANT)
|
||||
Q_INVOKABLE int sizeInGb();
|
||||
|
||||
signals:
|
||||
@@ -34,6 +35,7 @@ protected:
|
||||
quint64 _size;
|
||||
bool _isUsb;
|
||||
bool _isScsi;
|
||||
bool _isReadOnly;
|
||||
};
|
||||
|
||||
#endif // DRIVELISTITEM_H
|
||||
|
||||
+8
-6
@@ -18,6 +18,7 @@ DriveListModel::DriveListModel(QObject *parent)
|
||||
{sizeRole, "size"},
|
||||
{isUsbRole, "isUsb"},
|
||||
{isScsiRole, "isScsi"},
|
||||
{isReadOnlyRole, "isReadOnly"},
|
||||
{mountpointsRole, "mountpoints"}
|
||||
};
|
||||
|
||||
@@ -65,7 +66,7 @@ void DriveListModel::processDriveList(std::vector<Drivelist::DeviceDescriptor> l
|
||||
|
||||
if (filterSystemDrives)
|
||||
{
|
||||
if (i.isSystem || i.isReadOnly)
|
||||
if (i.isSystem)
|
||||
continue;
|
||||
|
||||
// Should already be caught by isSystem variable, but just in case...
|
||||
@@ -73,17 +74,18 @@ void DriveListModel::processDriveList(std::vector<Drivelist::DeviceDescriptor> l
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip zero-sized and virtual devices
|
||||
if (i.size == 0 || i.isVirtual)
|
||||
// Skip zero-sized devices
|
||||
if (i.size == 0)
|
||||
continue;
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
// Skip time machine backup. FIXME: is this best way to detect them?
|
||||
if (i.mountpointLabels.size() && i.mountpointLabels.front() == "Time Machine Backups")
|
||||
if (i.isVirtual)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
QString deviceNamePlusSize = QString::fromStdString(i.device)+":"+QString::number(i.size);
|
||||
if (i.isReadOnly)
|
||||
deviceNamePlusSize += "ro";
|
||||
drivesInNewList.insert(deviceNamePlusSize);
|
||||
|
||||
if (!_drivelist.contains(deviceNamePlusSize))
|
||||
@@ -95,7 +97,7 @@ void DriveListModel::processDriveList(std::vector<Drivelist::DeviceDescriptor> l
|
||||
changes = true;
|
||||
}
|
||||
|
||||
_drivelist[deviceNamePlusSize] = new DriveListItem(QString::fromStdString(i.device), QString::fromStdString(i.description), i.size, i.isUSB, i.isSCSI, mountpoints, this);
|
||||
_drivelist[deviceNamePlusSize] = new DriveListItem(QString::fromStdString(i.device), QString::fromStdString(i.description), i.size, i.isUSB, i.isSCSI, i.isReadOnly, mountpoints, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public:
|
||||
void stopPolling();
|
||||
|
||||
enum driveListRoles {
|
||||
deviceRole = Qt::UserRole + 1, descriptionRole, sizeRole, isUsbRole, isScsiRole, mountpointsRole
|
||||
deviceRole = Qt::UserRole + 1, descriptionRole, sizeRole, isUsbRole, isScsiRole, isReadOnlyRole, mountpointsRole
|
||||
};
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -615,24 +615,12 @@ ApplicationWindow {
|
||||
Keys.onSpacePressed: {
|
||||
if (currentIndex == -1)
|
||||
return
|
||||
|
||||
dstpopup.close()
|
||||
imageWriter.setDst(currentItem.device, currentItem.size)
|
||||
dstbutton.text = currentItem.description
|
||||
if (imageWriter.readyToWrite()) {
|
||||
writebutton.enabled = true
|
||||
}
|
||||
selectDstItem(currentItem)
|
||||
}
|
||||
Accessible.onPressAction: {
|
||||
if (currentIndex == -1)
|
||||
return
|
||||
|
||||
dstpopup.close()
|
||||
imageWriter.setDst(currentItem.device, currentItem.size)
|
||||
dstbutton.text = currentItem.description
|
||||
if (imageWriter.readyToWrite()) {
|
||||
writebutton.enabled = true
|
||||
}
|
||||
selectDstItem(currentItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -694,9 +682,20 @@ ApplicationWindow {
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
font.family: roboto.name
|
||||
text: {
|
||||
var txt = "<p><font size='4'>"+description+" - "+(size/1000000000).toFixed(1)+" GB"+"</font></p>"
|
||||
if (mountpoints.length > 0) {
|
||||
txt += "<font color='grey'>"+qsTr("Mounted as %1").arg(mountpoints.join(", "))+"</font>"
|
||||
var sizeStr = (size/1000000000).toFixed(1)+" GB";
|
||||
var txt;
|
||||
if (isReadOnly) {
|
||||
txt = "<p><font size='4' color='grey'>"+description+" - "+sizeStr+"</font></p>"
|
||||
txt += "<font color='grey'>"
|
||||
if (mountpoints.length > 0) {
|
||||
txt += qsTr("Mounted as %1").arg(mountpoints.join(", "))+" "
|
||||
}
|
||||
txt += qsTr("[WRITE PROTECTED]")+"</font>"
|
||||
} else {
|
||||
txt = "<p><font size='4'>"+description+" - "+sizeStr+"</font></p>"
|
||||
if (mountpoints.length > 0) {
|
||||
txt += "<font color='grey'>"+qsTr("Mounted as %1").arg(mountpoints.join(", "))+"</font>"
|
||||
}
|
||||
}
|
||||
return txt;
|
||||
}
|
||||
@@ -718,12 +717,7 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
dstpopup.close()
|
||||
imageWriter.setDst(device, size)
|
||||
dstbutton.text = description
|
||||
if (imageWriter.readyToWrite()) {
|
||||
writebutton.enabled = true
|
||||
}
|
||||
selectDstItem(model)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -988,4 +982,18 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selectDstItem(d) {
|
||||
if (d.isReadOnly) {
|
||||
onError(qsTr("SD card is write protected.<br>Push the lock switch on the left side of the card upwards, and try again."))
|
||||
return
|
||||
}
|
||||
|
||||
dstpopup.close()
|
||||
imageWriter.setDst(d.device, d.size)
|
||||
dstbutton.text = d.description
|
||||
if (imageWriter.readyToWrite()) {
|
||||
writebutton.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user