func:添加显示驱动器。
This commit is contained in:
@@ -11,7 +11,7 @@ LocalFile::LocalFile(QObject* parent) : DirFileHelper(parent)
|
||||
bool LocalFile::GetHome()
|
||||
{
|
||||
auto home = Util::GetUserHome();
|
||||
emit sigHome(home);
|
||||
emit sigHome(home, Util::GetLocalDrivers());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QMutex>
|
||||
#include <QStandardPaths>
|
||||
#include <QStorageInfo>
|
||||
#include <QUuid>
|
||||
#include <fversion.h>
|
||||
#include <iostream>
|
||||
@@ -154,6 +155,18 @@ QString Util::UUID()
|
||||
return QUuid::createUuid().toString().remove("{").remove("}");
|
||||
}
|
||||
|
||||
QVector<QString> Util::GetLocalDrivers()
|
||||
{
|
||||
QVector<QString> result;
|
||||
auto drivers = QStorageInfo::mountedVolumes();
|
||||
for (const auto& driver : drivers) {
|
||||
if (driver.isValid() && driver.isReady()) {
|
||||
result.push_back(driver.rootPath());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString DirFileHelper::GetErr() const
|
||||
{
|
||||
return QString();
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
static bool FileExist(const QString& path);
|
||||
static bool DirExist(const QString& path, bool isFilePath);
|
||||
static QString UUID();
|
||||
static QVector<QString> GetLocalDrivers();
|
||||
};
|
||||
|
||||
class DirFileHelper : public QObject
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
QString GetErr() const;
|
||||
|
||||
signals:
|
||||
void sigHome(const QString& path);
|
||||
void sigHome(const QString& path, const QStringList& drivers);
|
||||
void sigDirFile(const DirFileInfoVec& dirFile);
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user