func:添加显示驱动器。
This commit is contained in:
@@ -152,6 +152,7 @@ void ClientCore::UseFrame(QSharedPointer<FrameBuffer> frame)
|
||||
case FrameBufferType::FBT_CLI_ASK_HOME: {
|
||||
InfoMsg info;
|
||||
info.msg = Util::GetUserHome();
|
||||
info.list = Util::GetLocalDrivers();
|
||||
if (!Send<InfoMsg>(info, FBT_CLI_ANS_HOME, frame->fid)) {
|
||||
qCritical() << QString(tr("send home failed."));
|
||||
return;
|
||||
@@ -161,7 +162,7 @@ void ClientCore::UseFrame(QSharedPointer<FrameBuffer> frame)
|
||||
case FrameBufferType::FBT_CLI_ANS_HOME: {
|
||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||
qInfo() << QString(tr("用户目录:%1")).arg(info.msg);
|
||||
emit sigPath(info.msg);
|
||||
emit sigPath(info.msg, info.list);
|
||||
break;
|
||||
}
|
||||
case FrameBufferType::FBT_SER_MSG_FORWARD_FAILED: {
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
signals:
|
||||
void sigDisconnect();
|
||||
void sigPath(const QString& path);
|
||||
void sigPath(const QString& path, const QStringList& drivers);
|
||||
void sigClients(const InfoClientVec& clients);
|
||||
void sigFiles(const DirFileInfoVec& files);
|
||||
void sigReqSend(QSharedPointer<FrameBuffer> frame);
|
||||
|
||||
@@ -11,7 +11,8 @@ RemoteFile::RemoteFile(QObject* parent) : DirFileHelper(parent)
|
||||
void RemoteFile::setClientCore(ClientCore* cliCore)
|
||||
{
|
||||
cliCore_ = cliCore;
|
||||
connect(cliCore_, &ClientCore::sigPath, this, [this](const QString& path) { sigHome(path); });
|
||||
connect(cliCore_, &ClientCore::sigPath, this,
|
||||
[this](const QString& path, const QStringList& drivers) { sigHome(path, drivers); });
|
||||
connect(cliCore_, &ClientCore::sigFiles, this, [this](const DirFileInfoVec& files) { sigDirFile(files); });
|
||||
}
|
||||
|
||||
|
||||
@@ -109,17 +109,26 @@ void FileManager::InitMenu()
|
||||
menu_->addSeparator();
|
||||
}
|
||||
|
||||
void FileManager::ShowPath(const QString& path)
|
||||
void FileManager::ShowPath(const QString& path, const QStringList& drivers)
|
||||
{
|
||||
QMutexLocker locker(&cbMut_);
|
||||
|
||||
int existingIndex = ui->comboBox->findText(path);
|
||||
if (existingIndex != -1) {
|
||||
ui->comboBox->removeItem(existingIndex);
|
||||
} else if (ui->comboBox->count() >= 20) {
|
||||
ui->comboBox->removeItem(ui->comboBox->count() - 1);
|
||||
}
|
||||
for (const auto& driver : drivers) {
|
||||
if (ui->comboBox->findText(driver) == -1) {
|
||||
ui->comboBox->insertItem(0, driver);
|
||||
}
|
||||
}
|
||||
if (ui->comboBox->findText(path) == -1) {
|
||||
ui->comboBox->insertItem(0, path);
|
||||
}
|
||||
ui->comboBox->setCurrentIndex(0);
|
||||
drivers_ = drivers;
|
||||
}
|
||||
|
||||
void FileManager::ShowFile(const DirFileInfoVec& info)
|
||||
@@ -133,7 +142,7 @@ void FileManager::ShowFile(const DirFileInfoVec& info)
|
||||
RefreshTab();
|
||||
ui->tableWidget->resizeColumnToContents(0);
|
||||
SetRoot(currentInfo_.root);
|
||||
ShowPath(GetRoot());
|
||||
ShowPath(GetRoot(), drivers_);
|
||||
}
|
||||
|
||||
void FileManager::SetRoot(const QString& path)
|
||||
@@ -479,7 +488,7 @@ void FileManager::evtUp()
|
||||
auto r = fileHelper_->GetDirFile(path);
|
||||
if (r) {
|
||||
SetRoot(path);
|
||||
ShowPath(GetRoot());
|
||||
ShowPath(GetRoot(), drivers_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ signals:
|
||||
private:
|
||||
void InitControl();
|
||||
void InitMenu();
|
||||
void ShowPath(const QString& path);
|
||||
void ShowPath(const QString& path, const QStringList& drivers);
|
||||
void ShowFile(const DirFileInfoVec& info);
|
||||
void doubleClick(int row, int column);
|
||||
void SetRoot(const QString& path);
|
||||
@@ -70,6 +70,7 @@ private:
|
||||
ClientCore* cliCore_;
|
||||
QMutex cbMut_;
|
||||
QMutex tbMut_;
|
||||
QStringList drivers_;
|
||||
QSet<QString> fileTypes_;
|
||||
QSet<QString> curSelectTypes_;
|
||||
DirFileInfoVec currentInfo_;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
| 序号 | 类型 | 内容 | 说明 | 基于版本 | 完成版本 |
|
||||
| :--: | :--: | ------------------------------------------------------------ | :--: | :------: | :------: |
|
||||
| 32 | 功能 | 路径选择显示驱动器。 | | 0.2.2 | 0.2.3 |
|
||||
| 31 | 功能 | Server端buffer大小判断,有过多无效数据则踢出该客户端。 | | 0.2.2 | |
|
||||
| 30 | 功能 | 传输界面的取消退出,缺失功能处理。 | | 0.2.2 | 0.2.3 |
|
||||
| 29 | 功能 | 根据接收端的速率限制发送端的速度。 | | 0.2.2 | 0.2.3 |
|
||||
|
||||
@@ -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