mirror of https://gitee.com/openkylin/peony.git
通过KY_UDF_BURN宏以可选方式合入udf刻录新需求18331
This commit is contained in:
parent
a013f73868
commit
1474af0019
|
@ -111,6 +111,25 @@ void IconViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//get file info from index
|
||||
auto model = static_cast<FileItemProxyFilterSortModel*>(view->model());
|
||||
auto item = model->itemFromIndex(index);
|
||||
//NOTE: item might be deleted when painting, because we might start a
|
||||
//location change during the painting.
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
/* R类型光盘,所有用于刻录的文件(夹)展示在挂载点时都应该半透明显示,区别于普通文件 ,linkto task#122470 */
|
||||
if(item->property("isFileForBurning").toBool()){
|
||||
painter->setOpacity(0.5);
|
||||
}else{
|
||||
painter->setOpacity(1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
//default painter
|
||||
//QStyledItemDelegate::paint(painter, option, index);
|
||||
QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
|
||||
|
@ -233,14 +252,6 @@ void IconViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||
if (bCutFile && !getView()->getDelegateEditFlag())/* Rename is index is not set to nullptr,link to bug#61119.modified by 2021/06/22 */
|
||||
view->setIndexWidget(index, nullptr);
|
||||
|
||||
//get file info from index
|
||||
auto model = static_cast<FileItemProxyFilterSortModel*>(view->model());
|
||||
auto item = model->itemFromIndex(index);
|
||||
//NOTE: item might be deleted when painting, because we might start a
|
||||
//location change during the painting.
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
auto info = item->info();
|
||||
// draw color symbols
|
||||
int yoffset = 0;
|
||||
|
@ -392,7 +403,6 @@ void IconViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||
}
|
||||
painter->restore();
|
||||
|
||||
|
||||
//single selection, we have to repaint the emblems.
|
||||
|
||||
}
|
||||
|
|
|
@ -200,6 +200,20 @@ void IconViewIndexWidget::paintEvent(QPaintEvent *e)
|
|||
//qDebug()<<m_option.backgroundBrush;
|
||||
//qDebug()<<this->size() << m_delegate->getView()->iconSize();
|
||||
|
||||
auto model = static_cast<FileItemProxyFilterSortModel*>(view->model());
|
||||
auto item = model->itemFromIndex(m_index);
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
if (item) {
|
||||
/* R类型光盘,所有用于刻录的文件(夹)展示在挂载点时都应该半透明显示,区别于普通文件 ,linkto task#122470 */
|
||||
if(item->property("isFileForBurning").toBool()){
|
||||
p.setOpacity(0.5);
|
||||
}else{
|
||||
p.setOpacity(1.0);
|
||||
}
|
||||
}//end
|
||||
#endif
|
||||
|
||||
auto opt = m_option;
|
||||
auto rawRect = m_option.rect;
|
||||
opt.rect = this->rect();
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "file-operation-manager.h"
|
||||
#include "file-rename-operation.h"
|
||||
#include "file-item-model.h"
|
||||
#include "file-item-proxy-filter-sort-model.h"
|
||||
#include "file-item.h"
|
||||
|
||||
#include "list-view.h"
|
||||
#include "clipboard-utils.h"
|
||||
|
@ -68,6 +70,21 @@ void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||
|
||||
auto view = qobject_cast<DirectoryView::ListView *>(parent());
|
||||
opt.decorationSize = view->iconSize();
|
||||
|
||||
auto model = static_cast<FileItemProxyFilterSortModel*>(view->model());
|
||||
auto item = model->itemFromIndex(index);
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
if (item) {
|
||||
/* R类型光盘,所有用于刻录的文件(夹)展示在挂载点时都应该半透明显示,区别于普通文件 ,linkto task#122470 */
|
||||
if(item->property("isFileForBurning").toBool()){
|
||||
painter->setOpacity(0.5);
|
||||
}else{
|
||||
painter->setOpacity(1.0);
|
||||
}
|
||||
}//end
|
||||
#endif
|
||||
|
||||
/* 此处以中文命名的文件保护箱标记实时同步还存在问题,是由于uri编码(尽管使用FileUtils::urlEncoded进行转换)与底层(info的uri)不匹配 */
|
||||
QString uri = index.data(Qt::UserRole).toString();
|
||||
auto info = FileInfo::fromUri(uri);
|
||||
|
@ -328,6 +345,7 @@ void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QWidget *ListViewDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
|
|
|
@ -39,12 +39,13 @@
|
|||
|
||||
#ifndef KY_UDF_BURN
|
||||
#include "disccontrol.h"
|
||||
#include "udfFormatDialog.h"
|
||||
#else
|
||||
#include <libkyudfburn/disccontrol.h>
|
||||
#include "ky-udf-format-dialog.h"
|
||||
using namespace UdfBurn;
|
||||
#endif
|
||||
|
||||
#include "udfFormatDialog.h"
|
||||
#include <QDebug>
|
||||
#include <volume-manager.h>
|
||||
|
||||
|
@ -225,7 +226,7 @@ const QList<QAction *> SideBarMenu::constructFileSystemItemActions()
|
|||
if(discControl->work()){
|
||||
connect(discControl, &UdfBurn::DiscControl::workFinished, [=](UdfBurn::DiscControl *discCtrl){
|
||||
connect(action, &QAction::triggered, [=](){
|
||||
UdfBurn::UdfFormatDialog *udfFormatDlg = new UdfBurn::UdfFormatDialog(uri, discCtrl);
|
||||
UdfBurn::UdfFormatDialog *udfFormatDlg = new UdfFormatDialog(uri, discCtrl);
|
||||
udfFormatDlg->show();
|
||||
});
|
||||
qDebug()<<unixDevice<<" supported Udf values are:"<<discCtrl->supportUdf();
|
||||
|
@ -313,7 +314,7 @@ const QList<QAction *> SideBarMenu::constructNetWorkItemActions()
|
|||
if (!m_uri.startsWith("file://")) {
|
||||
l<<addAction(QIcon::fromTheme("media-eject-symbolic"), tr("Unmount"), [=]() {
|
||||
m_item->unmount();
|
||||
});
|
||||
});
|
||||
l.last()->setEnabled(m_item->isMounted());
|
||||
}
|
||||
if(netWorkUri != m_uri){
|
||||
|
@ -371,6 +372,3 @@ QString SideBarMenu::getComputerUriFromUnixDevice(const QString &unixDevice){
|
|||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@
|
|||
|
||||
#include <QApplication>
|
||||
|
||||
#define DEBUG qDebug() << "[" << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "]"
|
||||
|
||||
using namespace Peony;
|
||||
|
||||
static PushButtonStyle *global_instance = nullptr;
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "properties-window-tab-iface.h"
|
||||
#include "open-with-properties-page.h"
|
||||
|
||||
#define DEBUG qDebug() << "[" << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "]"
|
||||
#define CELL1K 1024
|
||||
#define CELL4K 4096
|
||||
#define CELL1M 1048576
|
||||
|
|
|
@ -21,18 +21,17 @@
|
|||
*/
|
||||
|
||||
#include "file-copy-operation.h"
|
||||
|
||||
#include "file-node-reporter.h"
|
||||
#include "file-node.h"
|
||||
#include "file-enumerator.h"
|
||||
#include "file-info.h"
|
||||
|
||||
#include "file-utils.h"
|
||||
|
||||
#include "file-operation-manager.h"
|
||||
#include "sound-effect.h"
|
||||
#include "clipboard-utils.h"
|
||||
#include <QProcess>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include "file-copy.h"
|
||||
#include <gio/gdesktopappinfo.h>
|
||||
|
@ -72,7 +71,6 @@ FileCopyOperation::FileCopyOperation(QStringList sourceUris, QString destDirUri,
|
|||
m_dest_dir_uri = FileUtils::urlDecode(destDirUri);
|
||||
m_reporter = new FileNodeReporter;
|
||||
connect(m_reporter, &FileNodeReporter::nodeFound, this, &FileOperation::operationPreparedOne);
|
||||
|
||||
m_info = std::make_shared<FileOperationInfo>(sourceUris, destDirUri, FileOperationInfo::Copy);
|
||||
}
|
||||
|
||||
|
@ -672,7 +670,7 @@ void FileCopyOperation::rollbackNodeRecursively(FileNode *node)
|
|||
g_file_delete(dest_file, nullptr, nullptr);
|
||||
g_object_unref(dest_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
operationRollbackedOne(node->destUri(), node->uri());
|
||||
break;
|
||||
}
|
||||
|
@ -705,6 +703,16 @@ void FileCopyOperation::run()
|
|||
|
||||
Q_EMIT operationStarted();
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
std::shared_ptr<FileOperationHelper> mHelper = std::make_shared<FileOperationHelper>(m_dest_dir_uri);
|
||||
if (mHelper->isUnixDevice()) {
|
||||
mHelper->judgeSpecialDiscOperation();
|
||||
if (!mHelper->dealDVDReduce().isEmpty()) {
|
||||
m_dest_dir_uri = mHelper->dealDVDReduce();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Q_EMIT operationRequestShowWizard();
|
||||
|
||||
goffset *total_size = new goffset(0);
|
||||
|
@ -753,8 +761,24 @@ void FileCopyOperation::run()
|
|||
}
|
||||
|
||||
m_info->m_dest_uris = m_info->m_node_map.values();
|
||||
|
||||
nodes.clear();
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
if (mHelper->isUnixDevice()) {
|
||||
if(!mHelper->discWriteOperation(m_source_uris, m_dest_dir_uri)) {
|
||||
FileOperationError except;
|
||||
except.errorType = ET_CUSTOM;
|
||||
except.op = FileOpCopy;
|
||||
except.title = tr("File copy error");
|
||||
except.srcUri = m_source_uris.first();
|
||||
except.errorStr = tr("Burn failed");
|
||||
except.destDirUri = m_dest_dir_uri;
|
||||
except.dlgType = ED_WARNING;
|
||||
Q_EMIT errored(except);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Q_EMIT operationFinished();
|
||||
sendSrcAndDestUrisOfCopyDspsFiles();
|
||||
}
|
||||
|
|
|
@ -90,6 +90,8 @@ private:
|
|||
QStringList m_source_uris;
|
||||
QString m_dest_dir_uri = nullptr;
|
||||
|
||||
QString m_disc_media_type = nullptr;
|
||||
bool m_is_disk_work = false;
|
||||
int m_current_count = 0;
|
||||
int m_total_count = 0;
|
||||
QSet<QString> m_conflict_files;
|
||||
|
|
|
@ -128,7 +128,6 @@ void FileDeleteOperation::run()
|
|||
return;
|
||||
|
||||
Q_EMIT operationStarted();
|
||||
|
||||
for (auto src : m_src_uris) {
|
||||
// pre-check for delete special directory
|
||||
if (src == "file:///data/home" || src == "file:///data/usershare" ||
|
||||
|
@ -193,6 +192,14 @@ void FileDeleteOperation::run()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
std::shared_ptr<FileOperationHelper> mHelper = std::make_shared<FileOperationHelper>(m_src_uris.first());
|
||||
if (mHelper->isUnixDevice()) {
|
||||
mHelper->judgeSpecialDiscOperation();
|
||||
mHelper->discDeleteOperation(m_src_uris);
|
||||
}
|
||||
#endif
|
||||
|
||||
Q_EMIT operationFinished();
|
||||
|
||||
qApp->property("clearTrash");
|
||||
|
|
|
@ -47,9 +47,12 @@ public:
|
|||
void cancel() override;
|
||||
|
||||
private:
|
||||
|
||||
int m_current_count = 0;
|
||||
int m_total_count = 0;
|
||||
QString m_current_src_uri = nullptr;
|
||||
QString m_disc_media_type = nullptr;
|
||||
bool m_is_disk_work = false;
|
||||
|
||||
goffset m_current_offset = 0;
|
||||
goffset m_total_szie = 0;
|
||||
|
|
|
@ -55,15 +55,16 @@ FileLinkOperation::~FileLinkOperation()
|
|||
|
||||
}
|
||||
|
||||
void FileLinkOperation::run()
|
||||
void FileLinkOperation::linkrun()
|
||||
{
|
||||
operationStarted();
|
||||
auto destFile = wrapGFile(g_file_new_for_uri(FileUtils::urlEncode(m_dest_uri).toUtf8().constData()));
|
||||
GError *err = nullptr;
|
||||
|
||||
retry:
|
||||
QUrl url = m_src_uri;
|
||||
g_file_make_symbolic_link(destFile.get()->get(), url.path().toUtf8().constData(), nullptr, &err);
|
||||
const char* symlinkValue = url.path().toUtf8().constData();
|
||||
g_file_make_symbolic_link(destFile.get()->get(), symlinkValue, nullptr, &err);
|
||||
qDebug() << err->message;
|
||||
if (err) {
|
||||
setHasError(true);
|
||||
//forbid response actions except retry and cancel.
|
||||
|
@ -103,9 +104,12 @@ end:
|
|||
|
||||
// maybe not need sync ???
|
||||
fileSync(m_src_uri, m_dest_uri);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FileLinkOperation::run()
|
||||
{
|
||||
operationStarted();
|
||||
linkrun();
|
||||
// judge if the operation should sync.
|
||||
// bool needSync = false;
|
||||
// GFile *src_first_file = g_file_new_for_uri(m_src_uri.toUtf8().constData());
|
||||
|
@ -144,3 +148,4 @@ end:
|
|||
operationFinished();
|
||||
//notifyFileWatcherOperationFinished();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
}
|
||||
void run() override;
|
||||
|
||||
void linkrun();
|
||||
|
||||
private:
|
||||
QString m_src_uri = nullptr;
|
||||
QString m_dest_uri = nullptr;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "file-info.h"
|
||||
|
||||
#include "file-operation-manager.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <file-copy.h>
|
||||
|
||||
|
@ -1205,6 +1205,23 @@ void FileMoveOperation::run()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
std::shared_ptr<FileOperationHelper> mHelper = std::make_shared<FileOperationHelper>(m_dest_dir_uri);
|
||||
if (mHelper->isUnixDevice()) {
|
||||
mHelper->judgeSpecialDiscOperation();
|
||||
if (!mHelper->dealDVDReduce().isEmpty()) {
|
||||
m_dest_dir_uri = mHelper->dealDVDReduce();
|
||||
if (isCancelled())
|
||||
return;
|
||||
//should block and wait for other object prepared.
|
||||
setCopyMove(true);
|
||||
setAction(Qt::CopyAction);
|
||||
moveForceUseFallback();
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
start:
|
||||
if (!isValid()) {
|
||||
FileOperationError except;
|
||||
|
@ -1240,7 +1257,22 @@ start:
|
|||
// }
|
||||
|
||||
end:
|
||||
#ifdef KY_UDF_BURN
|
||||
if (mHelper->isUnixDevice()) {
|
||||
if(!mHelper->discWriteOperation(m_src_uris, m_dest_dir_uri)) {
|
||||
FileOperationError except;
|
||||
except.errorType = ET_CUSTOM;
|
||||
except.op = FileOpMove;
|
||||
except.title = tr("Move file error");
|
||||
except.srcUri = m_src_uris.first();
|
||||
except.errorStr = tr("Burn failed");
|
||||
except.destDirUri = m_dest_dir_uri;
|
||||
except.dlgType = ED_WARNING;
|
||||
Q_EMIT errored(except);
|
||||
}
|
||||
}
|
||||
Q_EMIT operationFinished();
|
||||
#endif
|
||||
|
||||
sendSrcAndDestUrisOfCopyDspsFiles();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
#ifdef KY_UDF_BURN
|
||||
|
||||
#include "file-operation-helper.h"
|
||||
#include <libkyudfburn/datacdrom.h>
|
||||
#include <libkyudfburn/udfreadwrite.h>
|
||||
#include "gio/gio.h"
|
||||
#include <QDir>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Peony;
|
||||
|
||||
using namespace UdfBurn;
|
||||
|
||||
FileOperationHelper::FileOperationHelper(const QString destDir, QObject *parent) : QObject(parent)
|
||||
{
|
||||
matchingUnixDevice(destDir);
|
||||
}
|
||||
|
||||
FileOperationHelper::~FileOperationHelper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString FileOperationHelper::getDiscType()
|
||||
{
|
||||
return m_disc_media_type;
|
||||
}
|
||||
|
||||
bool FileOperationHelper::isUnixDevice()
|
||||
{
|
||||
if (m_unix_device.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void FileOperationHelper::judgeSpecialDiscOperation()
|
||||
{
|
||||
//获取光盘文件格式和光盘类型
|
||||
QString dbusPath = "/org/freedesktop/UDisks2/block_devices/";
|
||||
dbusPath.append(m_unix_device.split("/").back());
|
||||
QDBusInterface iface("org.freedesktop.UDisks2",dbusPath,"org.freedesktop.DBus.Properties",QDBusConnection::systemBus());
|
||||
QDBusReply<QVariant> reply = iface.call("Get", "org.freedesktop.UDisks2.Block", "IdType");
|
||||
if (reply.isValid()) {
|
||||
m_disc_system_type = reply.value().toString();
|
||||
qDebug() << "disc system type is:" << m_disc_system_type;
|
||||
}
|
||||
if (!m_disc_system_type.isEmpty()) {
|
||||
DataCDROM *cdrom = new DataCDROM(m_unix_device);
|
||||
m_disc_media_type = cdrom->getDiscType();
|
||||
qDebug() << "disc media type is:" << m_disc_media_type;
|
||||
delete cdrom;
|
||||
}
|
||||
}
|
||||
|
||||
QString FileOperationHelper::matchingUnixDevice(QString uri)
|
||||
{
|
||||
QString destPath = getDestName(uri);
|
||||
destPath = uri.remove(destPath);
|
||||
GFile *file = g_file_new_for_uri(destPath.toUtf8().constData());
|
||||
if (!file) {
|
||||
qDebug()<< "File creation Failure";
|
||||
g_object_unref(file);
|
||||
return m_unix_device;
|
||||
}
|
||||
GError *err = nullptr;
|
||||
GMount *mount = g_file_find_enclosing_mount(file, nullptr, &err);
|
||||
if (err) {
|
||||
qDebug()<< err->code <<err->message;
|
||||
g_error_free(err);
|
||||
g_object_unref(file);
|
||||
return m_unix_device;
|
||||
}
|
||||
g_object_unref(file);
|
||||
if (mount) {
|
||||
GVolume *volume = g_mount_get_volume(mount);
|
||||
char *device = g_volume_get_identifier(volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
|
||||
m_unix_device = device;
|
||||
}
|
||||
return m_unix_device;
|
||||
}
|
||||
|
||||
QString FileOperationHelper::dealDVDReduce()
|
||||
{
|
||||
if (0 == m_disc_media_type.compare("DVD-R")
|
||||
|| 0 == m_disc_media_type.compare("CD-R")
|
||||
|| 0 == m_disc_media_type.compare("DVD+R")
|
||||
|| 0 == m_disc_media_type.compare("DVD+R DL")) {
|
||||
QString destDir = QDir::homePath() + "/.cache";
|
||||
QDir dir = QDir(destDir);
|
||||
if (!dir.exists("KylinTransitBurner")) {
|
||||
dir.mkdir("KylinTransitBurner");
|
||||
}
|
||||
destDir.append("/KylinTransitBurner").prepend("file://");
|
||||
return destDir;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
bool FileOperationHelper::discWriteOperation(const QStringList &sourUrisList, const QString &destUri)
|
||||
{
|
||||
if (!m_disc_media_type.isNull()) {
|
||||
if (m_disc_media_type.contains("DVD-RW") || m_disc_media_type.contains("CD-RW")) {
|
||||
bool right;
|
||||
char* errinfo = (char*)malloc(1024);
|
||||
memset(errinfo, 0, 1024);
|
||||
QStringList list;
|
||||
GFile* destGfile = g_file_new_for_uri(destUri.toUtf8().constData());
|
||||
QString destName = g_file_get_path(destGfile);
|
||||
if (nullptr != destGfile) {
|
||||
g_object_unref(destGfile);
|
||||
}
|
||||
for(QString sourUri : sourUrisList) {
|
||||
GFile* sourGfile = g_file_new_for_uri(sourUri.toUtf8().constData());
|
||||
sourUri = g_file_get_path(sourGfile);
|
||||
sourUri = destName + "/" +sourUri.split("/").back();
|
||||
list << sourUri;
|
||||
if (nullptr != sourGfile) {
|
||||
g_object_unref(sourGfile);
|
||||
}
|
||||
}
|
||||
destName = getDestName(destUri);
|
||||
//创建UdfReadWrite类
|
||||
std::shared_ptr<UdfReadWrite> udfwrite = std::make_shared<UdfReadWrite>(m_unix_device,nullptr);
|
||||
//开启udfclient的初始化
|
||||
right = udfwrite->startUdfClient(&errinfo);
|
||||
if (!right) {
|
||||
m_disc_error_msg = errinfo;
|
||||
qDebug() << "udf clint error message: " << errinfo;
|
||||
for (QString filePath : list) {
|
||||
QFile file(filePath);
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
udfwrite->closeUdfClient();
|
||||
free(errinfo);
|
||||
return false;
|
||||
}
|
||||
//写单个数据
|
||||
//right = udfwrite->writeSingleData(&errinfo, m_source_uris);
|
||||
right = udfwrite->writeMultiData(&errinfo, list, destName);
|
||||
if (!right) {
|
||||
m_disc_error_msg = errinfo;
|
||||
qDebug() << "udf write error message: " << errinfo;
|
||||
for (QString filePath : list) {
|
||||
QFile file(filePath);
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
udfwrite->closeUdfClient();
|
||||
free(errinfo);
|
||||
return false;
|
||||
}
|
||||
//同步数据及关闭udfclient
|
||||
udfwrite->closeUdfClient();
|
||||
free(errinfo);
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileOperationHelper::discRenameOperation(const QString &oldName,const QString &newName)
|
||||
{
|
||||
if (!m_disc_media_type.isNull()) {
|
||||
if (m_disc_media_type.contains("DVD-RW") || m_disc_media_type.contains("CD-RW")) {
|
||||
bool right;
|
||||
char* errinfo = (char*)malloc(1024);
|
||||
memset(errinfo, 0, 1024);
|
||||
//创建UdfReadWrite类
|
||||
std::shared_ptr<UdfReadWrite> udfwrite = std::make_shared<UdfReadWrite>(m_unix_device,nullptr);
|
||||
//开启udfclient的初始化
|
||||
right = udfwrite->startUdfClient(&errinfo);
|
||||
if(!right) {
|
||||
qDebug() << "udf clint error message: " << errinfo;
|
||||
udfwrite->closeUdfClient();
|
||||
free(errinfo);
|
||||
return;
|
||||
}
|
||||
//重命名数据
|
||||
right = udfwrite->changeFileName(oldName, newName, &errinfo);
|
||||
|
||||
if(!right) {
|
||||
qDebug() << "udf rename error message: " << errinfo;
|
||||
}
|
||||
//同步数据及关闭udfclient
|
||||
udfwrite->closeUdfClient();
|
||||
free(errinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FileOperationHelper::discDeleteOperation(const QStringList &srcUris)
|
||||
{
|
||||
if (!m_disc_media_type.isNull()) {
|
||||
if (m_disc_media_type.contains("DVD-RW") || m_disc_media_type.contains("CD-RW")) {
|
||||
bool right;
|
||||
char* errinfo = (char*)malloc(1024);
|
||||
memset(errinfo, 0, 1024);
|
||||
QStringList list;
|
||||
for (QString srcUri : srcUris) {
|
||||
GFile* sourGfile = g_file_new_for_uri(srcUri.toUtf8().constData());
|
||||
srcUri = g_file_get_path(sourGfile);
|
||||
srcUri = getDestName(srcUri);
|
||||
list << srcUri;
|
||||
if (nullptr != sourGfile) {
|
||||
g_object_unref(sourGfile);
|
||||
}
|
||||
}
|
||||
//创建UdfReadWrite类
|
||||
std::shared_ptr<UdfReadWrite> udfwrite = std::make_shared<UdfReadWrite>(m_unix_device,nullptr);
|
||||
//开启udfclient的初始化
|
||||
right = udfwrite->startUdfClient(&errinfo);
|
||||
if(!right) {
|
||||
qDebug() << "udf clint error message: " << errinfo;
|
||||
free(errinfo);
|
||||
udfwrite->closeUdfClient();
|
||||
return;
|
||||
}
|
||||
//删除数据
|
||||
right = udfwrite->removeFile(list, &errinfo);
|
||||
if(!right) {
|
||||
qDebug() << "udf clint error message: " << errinfo;
|
||||
}
|
||||
//同步数据及关闭udfclient
|
||||
udfwrite->closeUdfClient();
|
||||
free(errinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString FileOperationHelper::getDestName(const QString &destUri)
|
||||
{
|
||||
QString destName = destUri;
|
||||
QStringList list;
|
||||
if (!destName.startsWith("/")) {
|
||||
list = destName.remove(0,14).split("/");
|
||||
} else {
|
||||
list = destName.remove(0,7).split("/");
|
||||
}
|
||||
if (2 == list.count()) {
|
||||
destName = QString("");
|
||||
} else {
|
||||
list.removeAt(1);
|
||||
list.pop_front();
|
||||
destName = list.join("/");
|
||||
}
|
||||
return destName;
|
||||
}
|
||||
|
||||
QString FileOperationHelper::getDiscError()
|
||||
{
|
||||
return m_disc_error_msg;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,53 @@
|
|||
#ifndef FILEOPERATIONHELPER_H
|
||||
#define FILEOPERATIONHELPER_H
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
|
||||
#include "file-operation.h"
|
||||
#include <QObject>
|
||||
|
||||
class FileOperationHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FileOperationHelper(const QString destDir,QObject *parent = nullptr);
|
||||
~FileOperationHelper();
|
||||
|
||||
void judgeSpecialDiscOperation();
|
||||
|
||||
QString getDiscType();
|
||||
|
||||
QString dealDVDReduce();
|
||||
|
||||
bool isUnixDevice();
|
||||
|
||||
bool discWriteOperation(const QStringList &sourUrisList, const QString &destUri);
|
||||
|
||||
void discRenameOperation(const QString &oldName,const QString &newName);
|
||||
|
||||
void discDeleteOperation(const QStringList &srcUris);
|
||||
|
||||
QString getDestName(const QString &destUri);
|
||||
|
||||
QString getDiscError();
|
||||
protected:
|
||||
/**
|
||||
* @brief matchingUnixDevice
|
||||
* @param uri
|
||||
* @return
|
||||
* Matches the device mount point
|
||||
*/
|
||||
QString matchingUnixDevice(QString uri);
|
||||
|
||||
private:
|
||||
bool m_is_disk_work = false;
|
||||
QString m_unix_device = nullptr;
|
||||
QString m_disc_media_type = nullptr;
|
||||
QString m_disc_system_type = nullptr;
|
||||
QString m_disc_error_msg = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // FILEOPERATIONHELPER_H
|
|
@ -33,6 +33,12 @@
|
|||
#include "peony-core_global.h"
|
||||
#include "file-operation-error-handler.h"
|
||||
#include "file-operation-manager.h"
|
||||
#include "file-operation-helper.h"
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
#include <libkyudfburn/disccontrol.h>
|
||||
#include <libkyudfburn/udfreadwrite.h>
|
||||
#endif
|
||||
|
||||
namespace Peony {
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ PKGCONFIG += gio-unix-2.0
|
|||
|
||||
HEADERS += \
|
||||
$$PWD/file-node.h \
|
||||
$$PWD/file-operation-helper.h \
|
||||
$$PWD/file-operation-internal-dialog.h \
|
||||
$$PWD/shared-file-link-operation.h \
|
||||
$$PWD/xatom-helper.h \
|
||||
|
@ -32,6 +33,7 @@ HEADERS += \
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/file-node.cpp \
|
||||
$$PWD/file-operation-helper.cpp \
|
||||
$$PWD/file-operation-internal-dialog.cpp \
|
||||
$$PWD/shared-file-link-operation.cpp \
|
||||
$$PWD/xatom-helper.cpp \
|
||||
|
|
|
@ -294,8 +294,18 @@ cancel:
|
|||
|
||||
fileSync(m_uri, destUri);
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
std::shared_ptr<FileOperationHelper> mHelper = std::make_shared<FileOperationHelper>(m_uri);
|
||||
if (mHelper->isUnixDevice()) {
|
||||
mHelper->judgeSpecialDiscOperation();
|
||||
QString oldNamePath = mHelper->getDestName(m_uri);
|
||||
mHelper->discRenameOperation(oldNamePath, m_new_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
Q_EMIT operationFinished();
|
||||
//notifyFileWatcherOperationFinished();
|
||||
|
||||
}
|
||||
|
||||
#include <QFileInfo>
|
||||
|
|
|
@ -80,7 +80,7 @@ unix {
|
|||
# fixme:// format_dialog.h
|
||||
header.path = /usr/include/peony-qt
|
||||
header.files += *.h model/*.h file-operation/*.h vfs/*.h controls/ ../plugin-iface/*.h convenient-utils/*.h convenient-utils/disc/*.h windows/format_dialog.h windows/FMWindowIface.h \
|
||||
libpeony-qt/usershare-manager.h windows/udfFormatDialog.h
|
||||
libpeony-qt/usershare-manager.h windows/udfFormatDialog.h windows/udfAppendBurnDataDialog.h
|
||||
# header.depends = header2
|
||||
header.files += development-files/header-files/*
|
||||
INSTALLS += header
|
||||
|
@ -97,5 +97,3 @@ unix {
|
|||
#QM_FILES_RESOURCE_PREFIX = ../translations/libpeony-qt
|
||||
QM_FILES_INSTALL_PATH = /usr/share/libpeony-qt
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,10 +35,16 @@
|
|||
#include "gerror-wrapper.h"
|
||||
#include "bookmark-manager.h"
|
||||
#include "audio-play-manager.h"
|
||||
#ifndef KY_UDF_BURN
|
||||
#include "disccontrol.h"
|
||||
#else
|
||||
#include <libkyudfburn/disccontrol.h>
|
||||
using namespace UdfBurn;
|
||||
#endif
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QUrl>
|
||||
#include <QTimer>
|
||||
|
@ -370,6 +376,10 @@ void FileItem::findChildrenAsync()
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/* 如果是R类型光盘,遍历完当前目录后,再遍历将要刻录的缓冲数据加入item的m_children列表 */
|
||||
showFilesForBurningOnRTypeDisc();
|
||||
|
||||
enumerator->cancel();
|
||||
delete enumerator;
|
||||
|
||||
|
@ -473,6 +483,9 @@ void FileItem::findChildrenAsync()
|
|||
if (!m_model||!m_children||!m_info)
|
||||
return;
|
||||
|
||||
/* 如果是R类型光盘,遍历完当前目录后,再遍历将要刻录的缓冲数据加入item的m_children列表 */
|
||||
showFilesForBurningOnRTypeDisc();
|
||||
|
||||
m_watcher = std::make_shared<FileWatcher>(this->m_info->uri(), nullptr, true);
|
||||
m_watcher->setMonitorChildrenChange(true);
|
||||
connect(m_watcher.get(), &FileWatcher::fileCreated, this, [=](QString uri) {
|
||||
|
@ -590,6 +603,11 @@ void FileItem::onChildAdded(const QString &uri)
|
|||
// add exsited checkment. link to: #66999
|
||||
if (!item) {
|
||||
item = new FileItem(info, this, m_model);
|
||||
#ifdef KY_UDF_BURN
|
||||
if(m_isRTypeDisc){
|
||||
item->setProperty("isFileForBurning", true);
|
||||
}
|
||||
#endif
|
||||
m_model->beginInsertRows(QModelIndex(), m_children->count(), m_children->count());
|
||||
m_children->append(item);
|
||||
m_uri_item_hash.insert(item->uri(), item);
|
||||
|
@ -844,6 +862,71 @@ void FileItem::batchRemoveItems()
|
|||
}
|
||||
}
|
||||
|
||||
void FileItem::showFilesForBurningOnRTypeDisc()
|
||||
{
|
||||
#ifdef KY_UDF_BURN
|
||||
QString unixDevice = m_info.get()->unixDeviceFile();
|
||||
if(!unixDevice.startsWith("/dev/sr"))
|
||||
return;
|
||||
|
||||
DiscControl *discControl = new DiscControl(unixDevice);
|
||||
if(discControl->work()){
|
||||
connect(discControl, &DiscControl::workFinished, [=](DiscControl *discCtrl){
|
||||
if(discControl->isAllRType()){
|
||||
m_isRTypeDisc = true;
|
||||
FileEnumerator e;
|
||||
QString parentDirForBurnFiles = "file://" + QDir::homePath()+"/.cache/KylinTransitBurner/";/* 例:file:///home/kylin/.cache/KylinTransitBurner */
|
||||
e.setEnumerateDirectory(parentDirForBurnFiles);
|
||||
e.enumerateSync();
|
||||
for(auto &fileInfo : e.getChildren()){
|
||||
auto info = FileInfo::fromUri(fileInfo.get()->uri());
|
||||
auto infoJob = new FileInfoJob(info);
|
||||
infoJob->setAutoDelete();
|
||||
infoJob->connect(infoJob, &FileInfoJob::infoUpdated, this, [=]() {
|
||||
if(m_uri_item_hash.contains(info.get()->uri()))
|
||||
return;
|
||||
auto item = new FileItem(info, this, m_model);
|
||||
item->setProperty("isFileForBurning", true);/* 所有"/home/家目录/.cache/KylinTransitBurner/"中的子文件展示在挂载点时都应该半透明显示,区别于普通文件 */
|
||||
m_model->beginInsertRows(QModelIndex(), m_children->count(), m_children->count());
|
||||
m_children->append(item);
|
||||
m_uri_item_hash.insert(item->uri(), item);
|
||||
m_model->endInsertRows();
|
||||
ThumbnailManager::getInstance()->createThumbnail(info->uri(), m_thumbnail_watcher);
|
||||
});
|
||||
infoJob->queryAsync();
|
||||
}
|
||||
/* 监听 */
|
||||
m_rTypeDiscWatcher = std::make_shared<FileWatcher>(parentDirForBurnFiles, nullptr, true);
|
||||
m_rTypeDiscWatcher->setMonitorChildrenChange(true);
|
||||
connect(m_rTypeDiscWatcher.get(), &FileWatcher::fileCreated, this, [=](QString uri) {
|
||||
this->onChildAdded(uri);
|
||||
Q_EMIT this->childAdded(uri);
|
||||
ThumbnailManager::getInstance()->createThumbnail(uri, m_thumbnail_watcher, true);
|
||||
});
|
||||
connect(m_rTypeDiscWatcher.get(), &FileWatcher::fileDeleted, this, [=](QString uri) {
|
||||
this->onChildRemoved(uri);
|
||||
});
|
||||
connect(m_rTypeDiscWatcher.get(), &FileWatcher::fileChanged, this, [=](const QString &uri) {
|
||||
onChanged(uri);
|
||||
});
|
||||
connect(m_rTypeDiscWatcher.get(), &FileWatcher::fileRenamed, this, [=](const QString &oldUri, const QString &newUri) {
|
||||
this->onRenamed(oldUri, newUri);
|
||||
BookMarkManager::getInstance()->bookmarkChanged(oldUri, newUri);
|
||||
});
|
||||
connect(m_rTypeDiscWatcher.get(), &FileWatcher::thumbnailUpdated, this, [=](const QString &uri) {
|
||||
m_model->updated();
|
||||
});
|
||||
m_rTypeDiscWatcher->startMonitor();
|
||||
}
|
||||
if(discControl){
|
||||
discControl->deleteLater();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void FileItem::clearChildren()
|
||||
{
|
||||
auto parent = firstColumnIndex();
|
||||
|
@ -856,6 +939,8 @@ void FileItem::clearChildren()
|
|||
m_expanded = false;
|
||||
m_watcher.reset();
|
||||
m_watcher = nullptr;
|
||||
m_rTypeDiscWatcher.reset();
|
||||
m_rTypeDiscWatcher = nullptr;
|
||||
}
|
||||
|
||||
/* Func: if it isn't a vaild volume device,it should not be displayed.
|
||||
|
|
|
@ -148,6 +148,8 @@ protected:
|
|||
void removeChildren();
|
||||
void batchRemoveItems();
|
||||
|
||||
void showFilesForBurningOnRTypeDisc();/* udf刻录与文管适配,R类型光盘遍历家目录下的“.cache/KylinTransitBurner/”获取缓冲数据;将缓冲数据显示在光盘挂载目录下 */
|
||||
|
||||
private:
|
||||
FileItem *m_parent = nullptr;
|
||||
std::shared_ptr<Peony::FileInfo> m_info;
|
||||
|
@ -156,8 +158,10 @@ private:
|
|||
FileItemModel *m_model = nullptr;
|
||||
|
||||
bool m_expanded = false;
|
||||
bool m_isRTypeDisc = false;
|
||||
|
||||
std::shared_ptr<FileWatcher> m_watcher = nullptr;
|
||||
std::shared_ptr<FileWatcher> m_rTypeDiscWatcher = nullptr;/* R类型光盘刻录缓冲数据的监听 */
|
||||
std::shared_ptr<FileWatcher> m_thumbnail_watcher = nullptr;
|
||||
|
||||
QStringList m_ending_uris;
|
||||
|
|
|
@ -0,0 +1,207 @@
|
|||
#ifdef KY_UDF_BURN
|
||||
|
||||
#include "udfAppendBurnDataDialog.h"
|
||||
#include <libkyudfburn/disccontrol.h>
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
#include "file-enumerator.h"
|
||||
#include "file-info-job.h"
|
||||
#include "file-info.h"
|
||||
|
||||
static bool b_canClose = true;
|
||||
|
||||
using namespace UdfBurn;
|
||||
|
||||
UdfAppendBurnDataDialog::UdfAppendBurnDataDialog(const QString &uri, DiscControl *discControl, QWidget *parent):
|
||||
QDialog(parent), m_uri(uri),m_discControl(discControl)
|
||||
{
|
||||
|
||||
setAutoFillBackground(true);
|
||||
setWindowTitle(tr("AppendBurnData"));
|
||||
setBackgroundRole(QPalette::Base);
|
||||
setContentsMargins(24,24,24,24);
|
||||
setFixedSize(m_widgetWidth, m_widgetHeight);
|
||||
setWindowIcon(QIcon::fromTheme("system-file-manager"));
|
||||
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
|
||||
m_mainLayout = new QGridLayout(this);
|
||||
m_mainLayout->setMargin(0);
|
||||
m_mainLayout->setHorizontalSpacing(10);
|
||||
m_mainLayout->setVerticalSpacing(28);
|
||||
|
||||
m_discTypeLabel = new QLabel;
|
||||
m_discTypeLabel->setText(tr("Disc Type:"));
|
||||
m_discTypeEdit = new QLineEdit;
|
||||
m_discTypeEdit->setReadOnly(true);
|
||||
m_discTypeEdit->setEnabled(false);
|
||||
m_mainLayout->addWidget(m_discTypeLabel, 1, 1, 1, 2);
|
||||
m_mainLayout->addWidget(m_discTypeEdit, 1, 3, 1, 8);
|
||||
|
||||
m_discNameLabel = new QLabel;
|
||||
m_discNameLabel->setText(tr("Device Name:"));
|
||||
m_discNameEdit = new QLineEdit;
|
||||
m_mainLayout->addWidget(m_discNameLabel, 2, 1, 1, 2);
|
||||
m_mainLayout->addWidget(m_discNameEdit, 2, 3, 1, 8);
|
||||
|
||||
m_progress = new QProgressBar;
|
||||
m_progress->setMinimum(0);
|
||||
m_progress->setValue(0);
|
||||
m_progress->setTextVisible(false);
|
||||
m_progress->setVisible(false);
|
||||
m_mainLayout->addWidget(m_progress, 3, 1, 1, 8);
|
||||
|
||||
m_okBtn = new QPushButton;
|
||||
m_okBtn->setText(tr("OK"));
|
||||
m_cancelBtn = new QPushButton;
|
||||
m_cancelBtn->setText(tr("Cancel"));
|
||||
m_mainLayout->addWidget(m_cancelBtn, 4, 5, 1, 2);
|
||||
m_mainLayout->addWidget(m_okBtn, 4, 7, 1, 2);
|
||||
|
||||
|
||||
QString discType = m_discControl->discMediaType();
|
||||
QString discName = m_discControl->discLabel();
|
||||
if (discType.isEmpty()) {
|
||||
m_discTypeEdit->setText(tr("Unknow"));
|
||||
} else {
|
||||
m_discTypeEdit->setText(discType);
|
||||
}
|
||||
m_discNameEdit->setText(discName);
|
||||
b_canClose = true;
|
||||
|
||||
connect(m_okBtn, &QPushButton::clicked, this, &UdfAppendBurnDataDialog::slot_udfAppendBurnData, Qt::UniqueConnection);
|
||||
connect(m_cancelBtn, &QPushButton::clicked, this, &UdfAppendBurnDataDialog::slot_udfAppendBurnDataCancel, Qt::UniqueConnection);
|
||||
connect(m_discControl, &DiscControl::appendBurnDataUdfFinished, this, &UdfAppendBurnDataDialog::slot_appendBurnDataFinished, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
UdfAppendBurnDataDialog::~UdfAppendBurnDataDialog()
|
||||
{
|
||||
if(m_discControl){
|
||||
m_discControl->deleteLater();
|
||||
m_discControl = nullptr;
|
||||
}
|
||||
if(m_thread){
|
||||
m_thread->quit();
|
||||
m_thread->deleteLater();
|
||||
m_thread = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void UdfAppendBurnDataDialog::slot_udfAppendBurnDataCancel()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void UdfAppendBurnDataDialog::slot_udfAppendBurnData()
|
||||
{
|
||||
qDebug() << "begin slot_udappendBurnData";
|
||||
|
||||
/* R类型光盘,讲缓存刻录数据的临时目录绝对路径传入刻录接口进行刻录操作 */
|
||||
QString parentDirForBurnFiles = QDir::homePath()+"/.cache/KylinTransitBurner/";
|
||||
m_urisOfBurningCachedData.clear();
|
||||
|
||||
Peony::FileEnumerator e;
|
||||
e.setEnumerateDirectory(QString("file://").append(parentDirForBurnFiles));
|
||||
e.enumerateSync();
|
||||
if(e.getChildren().size() <= 0){
|
||||
QMessageBox::warning(nullptr, tr("Warning"), tr("No burn data, please add!"), QMessageBox::Ok);
|
||||
setButtonState(false);
|
||||
m_urisOfBurningCachedData.clear();
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
for(auto &fileInfo : e.getChildren()){
|
||||
m_urisOfBurningCachedData.append(fileInfo.get()->uri());
|
||||
}
|
||||
|
||||
setButtonState(true);
|
||||
if (!udfAppendBurnDataEnsureMsgBox()) {
|
||||
setButtonState(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_discNameEdit->text().isEmpty()) {
|
||||
QMessageBox::warning(nullptr, tr("Warning"), tr("The disc name cannot be set to empty, please re-enter it!"), QMessageBox::Ok);
|
||||
setButtonState(false);
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "卷标名称为: " << m_discNameEdit->text();
|
||||
|
||||
m_progress->setVisible(true);
|
||||
m_progress->setMaximum(0);
|
||||
b_canClose = false;
|
||||
|
||||
/* udf追加刻录线程 */
|
||||
m_thread = new QThread();
|
||||
m_discControl->moveToThread(m_thread);
|
||||
connect(m_thread, &QThread::started, m_discControl, [=](){
|
||||
m_discControl->appendBurnDataUdfSync(m_discNameEdit->text(), parentDirForBurnFiles);
|
||||
}, Qt::UniqueConnection);
|
||||
connect(m_thread, &QThread::finished, m_thread, &QThread::deleteLater, Qt::UniqueConnection);
|
||||
connect(m_thread, &QThread::finished, m_discControl, &DiscControl::deleteLater, Qt::UniqueConnection);
|
||||
m_thread->start();
|
||||
}
|
||||
|
||||
#include "file-operation-utils.h"
|
||||
void UdfAppendBurnDataDialog::slot_appendBurnDataFinished(bool successful, QString errorInfo)
|
||||
{
|
||||
m_thread->quit();
|
||||
|
||||
b_canClose = true;
|
||||
m_progress->setVisible(false);
|
||||
setButtonState(false);
|
||||
|
||||
if (successful) {
|
||||
QMessageBox::about(this, tr("AppendBurnData"), tr("AppendBurnData operation has been finished successfully."));
|
||||
/* 刻录操作完成后需要手动清空刻录缓存数据即'.cache/KylinTransitBurner/' */
|
||||
Peony::FileOperationUtils::remove(m_urisOfBurningCachedData);
|
||||
|
||||
} else {
|
||||
if(errorInfo.isEmpty())
|
||||
errorInfo = tr("Sorry, the appendBurnData operation is failed!");
|
||||
QMessageBox::critical(this, tr("Failed"), errorInfo, QMessageBox::Ok);
|
||||
}
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
void UdfAppendBurnDataDialog::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
if (!b_canClose) {
|
||||
QMessageBox::warning(nullptr, tr("Burning. Do not close this window"), tr("Burning. Do not close this window"), QMessageBox::Ok);
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool UdfAppendBurnDataDialog::udfAppendBurnDataEnsureMsgBox()
|
||||
{
|
||||
QMessageBox ensureMsgBox(this);
|
||||
ensureMsgBox.setText(tr("Burning this disc will append datas on it. Do you want to continue ?"));
|
||||
ensureMsgBox.setWindowTitle(tr("Burn"));
|
||||
|
||||
QPushButton* okBtn = ensureMsgBox.addButton(tr("Begin Burning"), QMessageBox::YesRole);
|
||||
QPushButton* cancelBtn = ensureMsgBox.addButton(tr("Close"), QMessageBox::NoRole);
|
||||
|
||||
ensureMsgBox.exec();
|
||||
|
||||
if (ensureMsgBox.clickedButton() == cancelBtn) {
|
||||
setButtonState(false);
|
||||
return false;
|
||||
} else if (ensureMsgBox.clickedButton() == okBtn) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UdfAppendBurnDataDialog::setButtonState(bool state)
|
||||
{
|
||||
m_okBtn->setDisabled(state);
|
||||
m_cancelBtn->setDisabled(state);
|
||||
m_discNameEdit->setDisabled(state);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,70 @@
|
|||
#ifndef UDFAPPENDBURNDATADIALOG_H
|
||||
#define UDFAPPENDBURNDATADIALOG_H
|
||||
|
||||
#ifdef KY_UDF_BURN
|
||||
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QProgressBar>
|
||||
#include <QGridLayout>
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include "peony-core_global.h"
|
||||
|
||||
class QThread;
|
||||
|
||||
namespace UdfBurn {
|
||||
|
||||
class DiscControl;
|
||||
|
||||
class PEONYCORESHARED_EXPORT UdfAppendBurnDataDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UdfAppendBurnDataDialog(const QString &uri, DiscControl *discControl,QWidget *parent = nullptr);
|
||||
virtual ~UdfAppendBurnDataDialog();
|
||||
|
||||
private:
|
||||
QString m_uri;
|
||||
DiscControl *m_discControl = nullptr;
|
||||
QThread *m_thread = nullptr;
|
||||
|
||||
const int m_widgetWidth = 424;
|
||||
const int m_widgetHeight = 300;
|
||||
|
||||
QLabel* m_discTypeLabel = nullptr;
|
||||
QLabel* m_discNameLabel = nullptr;
|
||||
|
||||
QLineEdit* m_discTypeEdit = nullptr;
|
||||
QLineEdit* m_discNameEdit = nullptr;
|
||||
|
||||
QPushButton* m_okBtn = nullptr;
|
||||
QPushButton* m_cancelBtn = nullptr;
|
||||
|
||||
QProgressBar* m_progress = nullptr;
|
||||
QGridLayout* m_mainLayout = nullptr;
|
||||
|
||||
QStringList m_urisOfBurningCachedData;
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void slot_udfAppendBurnData();
|
||||
void slot_udfAppendBurnDataCancel();
|
||||
void slot_appendBurnDataFinished(bool successful, QString errorInfo);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *) override;
|
||||
|
||||
private:
|
||||
bool udfAppendBurnDataEnsureMsgBox();
|
||||
void setButtonState(bool state);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // UDFAPPENDBURNDATADIALOG_H
|
|
@ -91,6 +91,7 @@ UdfFormatDialog::~UdfFormatDialog()
|
|||
|
||||
void UdfFormatDialog::slot_udfFormat()
|
||||
{
|
||||
qDebug() << "begin slot_udformat";
|
||||
setButtonState(true);
|
||||
if (!udfFormatEnsureMsgBox()) {
|
||||
setButtonState(false);
|
||||
|
@ -103,6 +104,8 @@ void UdfFormatDialog::slot_udfFormat()
|
|||
return;
|
||||
}
|
||||
|
||||
qDebug() << "卷标名称为: " << m_discNameEdit->text();
|
||||
|
||||
m_progress->setVisible(true);
|
||||
m_progress->setMaximum(0);
|
||||
b_canClose = false;
|
||||
|
|
|
@ -7,7 +7,8 @@ HEADERS += \
|
|||
$$PWD/format_dialog.h \
|
||||
$$PWD/ky-udf-format-dialog.h \
|
||||
$$PWD/properties-window.h \
|
||||
$$PWD/udfFormatDialog.h
|
||||
$$PWD/udfFormatDialog.h \
|
||||
$$PWD/udfAppendBurnDataDialog.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/fm-window-factory.cpp \
|
||||
|
@ -15,9 +16,8 @@ SOURCES += \
|
|||
$$PWD/format_dialog.cpp \
|
||||
$$PWD/ky-udf-format-dialog.cpp \
|
||||
$$PWD/properties-window.cpp \
|
||||
$$PWD/udfFormatDialog.cpp
|
||||
$$PWD/udfFormatDialog.cpp \
|
||||
$$PWD/udfAppendBurnDataDialog.cpp
|
||||
|
||||
FORMS += \
|
||||
$$PWD/format_dialog.ui
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue