From 067f4b6ce6954e1afd780a66c9dbac8b9e980b07 Mon Sep 17 00:00:00 2001 From: taynpg Date: Tue, 11 Nov 2025 22:57:38 +0800 Subject: [PATCH] =?UTF-8?q?pro=EF=BC=9A=E5=88=9D=E6=AD=A5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=B1=9E=E6=80=A7=E7=AA=97=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gui/CMakeLists.txt | 1 + Gui/Control/FileControl.cpp | 19 +++++ Gui/Control/FileControl.h | 1 + Gui/Form/FileInfoForm.cpp | 31 ++++++++ Gui/Form/FileInfoForm.h | 34 +++++++++ Gui/Form/FileInfoForm.ui | 148 ++++++++++++++++++++++++++++++++++++ 6 files changed, 234 insertions(+) create mode 100644 Gui/Form/FileInfoForm.cpp create mode 100644 Gui/Form/FileInfoForm.h create mode 100644 Gui/Form/FileInfoForm.ui diff --git a/Gui/CMakeLists.txt b/Gui/CMakeLists.txt index ce39bbf..6be9821 100644 --- a/Gui/CMakeLists.txt +++ b/Gui/CMakeLists.txt @@ -28,6 +28,7 @@ Control/cpTableWidget.h Control/cpTableWidget.cpp GuiUtil/Config.h GuiUtil/Config.cpp ../Res/qss.qrc Form/Loading.h Form/Loading.cpp Control/Common.h Control/Common.cpp +Form/FileInfoForm.h Form/FileInfoForm.cpp Form/FileInfoForm.ui ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) diff --git a/Gui/Control/FileControl.cpp b/Gui/Control/FileControl.cpp index 23b2169..09cc41e 100644 --- a/Gui/Control/FileControl.cpp +++ b/Gui/Control/FileControl.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "Form/FileInfoForm.h" #include "GuiUtil/Public.h" #include "ui_FileControl.h" @@ -106,6 +107,7 @@ void FileManager::InitMenu() menu_ = new QMenu(ui->tableWidget); menu_->addAction(tr("过滤器"), this, &FileManager::ShowFilterForm); menu_->addAction(tr("复制文件路径"), this, &FileManager::CopyFullPath); + menu_->addAction(tr("属性"), this, &FileManager::ShowProperties); menu_->addSeparator(); } @@ -452,6 +454,23 @@ void FileManager::CopyFullPath() } } +void FileManager::ShowProperties() +{ + int row = ui->tableWidget->currentRow(); + if (row < 0) { + return; + } + auto* info = new FileInfo(this); + + info->baseName_ = ui->tableWidget->item(row, 1)->text(); + info->dirName_ = isRemote_ ? GlobalData::Ins()->GetRemoteRoot() : GlobalData::Ins()->GetLocalRoot(); + info->fileTime_ = ui->tableWidget->item(row, 2)->text(); + info->fileType_ = ui->tableWidget->item(row, 3)->text(); + info->fileSize_ = ui->tableWidget->item(row, 4)->text(); + + info->exec(); +} + QString FileManager::GetRoot() { if (isRemote_) { diff --git a/Gui/Control/FileControl.h b/Gui/Control/FileControl.h index 090d542..a27bae2 100644 --- a/Gui/Control/FileControl.h +++ b/Gui/Control/FileControl.h @@ -56,6 +56,7 @@ private: void GenFilter(); void ShowFilterForm(); void CopyFullPath(); + void ShowProperties(); public slots: void evtHome(); diff --git a/Gui/Form/FileInfoForm.cpp b/Gui/Form/FileInfoForm.cpp new file mode 100644 index 0000000..cec459b --- /dev/null +++ b/Gui/Form/FileInfoForm.cpp @@ -0,0 +1,31 @@ +#include "FileInfoForm.h" + +#include "ui_FileInfoForm.h" + +FileInfo::FileInfo(QWidget* parent) : QDialog(parent), ui(new Ui::FileInfo) +{ + ui->setupUi(this); + InitControl(); + setWindowTitle(tr("属性")); +} + +FileInfo::~FileInfo() +{ + delete ui; +} + +int FileInfo::exec() +{ + ui->pedDir->setPlainText(dirName_); + ui->pedName->setPlainText(baseName_); + ui->lbSize->setText(fileSize_); + ui->lbTime->setText(fileTime_); + ui->lbType->setText(fileType_); + return QDialog::exec(); +} + +void FileInfo::InitControl() +{ + ui->pedDir->setReadOnly(true); + ui->pedName->setReadOnly(true); +} diff --git a/Gui/Form/FileInfoForm.h b/Gui/Form/FileInfoForm.h new file mode 100644 index 0000000..6d3fd7c --- /dev/null +++ b/Gui/Form/FileInfoForm.h @@ -0,0 +1,34 @@ +#ifndef FILEINFOFORM_H +#define FILEINFOFORM_H + +#include + +namespace Ui { +class FileInfo; +} + +class FileInfo : public QDialog +{ + Q_OBJECT + +public: + explicit FileInfo(QWidget* parent = nullptr); + ~FileInfo(); + + int exec() override; + +public: + QString baseName_; + QString dirName_; + QString fileType_; + QString fileTime_; + QString fileSize_; + +private: + void InitControl(); + +private: + Ui::FileInfo* ui; +}; + +#endif // FILEINFOFORM_H diff --git a/Gui/Form/FileInfoForm.ui b/Gui/Form/FileInfoForm.ui new file mode 100644 index 0000000..a1a30bd --- /dev/null +++ b/Gui/Form/FileInfoForm.ui @@ -0,0 +1,148 @@ + + + FileInfo + + + + 0 + 0 + 544 + 300 + + + + Dialog + + + + + + + + 类型: + + + + + + + TYPE + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + TIME + + + + + + + + + + + 名称: + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + SIZE + + + + + + + + + + + + 目录: + + + + + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + 复制文件名 + + + + + + + 复制目录 + + + + + + + 复制全路径 + + + + + + + 关闭 + + + + + + + + + +