diff --git a/src/source/archivemanager/archivemanager.cpp b/src/source/archivemanager/archivemanager.cpp index ee4c52fc..34a2dd3e 100644 --- a/src/source/archivemanager/archivemanager.cpp +++ b/src/source/archivemanager/archivemanager.cpp @@ -37,6 +37,7 @@ ArchiveManager::~ArchiveManager() ArchiveManager *ArchiveManager::get_instance() { + // qDebug() << "get_instance called"; #ifndef Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE if (!QAtomicPointer::isTestAndSetNative()) //运行时检测 qInfo() << "Error: TestAndSetNative not supported!"; @@ -48,6 +49,7 @@ ArchiveManager *ArchiveManager::get_instance() * 不会被重新排序。 */ if (m_instance.testAndSetOrdered(nullptr, nullptr)) { //第一次检测 + qDebug() << "Creating new ArchiveManager instance"; QMutexLocker locker(&m_mutex);//加互斥锁。 m_instance.testAndSetOrdered(nullptr, new ArchiveManager);//第二次检测。 @@ -58,6 +60,7 @@ ArchiveManager *ArchiveManager::get_instance() void ArchiveManager::destory_instance() { + qDebug() << "destroy_instance called"; SAFE_DELETE_ELE(m_instance) } @@ -74,9 +77,11 @@ bool ArchiveManager::createArchive(const QList &files, const QString qWarning() << "Path control check failed for destination:" << strDestination; return false; } + qDebug() << "Creating interface for destination"; m_pTempInterface = UiTools::createInterface(strDestination, true, eType); if (m_pTempInterface) { + qDebug() << "Creating CreateJob"; CreateJob *pCreateJob = new CreateJob(files, m_pTempInterface, stOptions, this); // 连接槽函数 @@ -111,9 +116,11 @@ bool ArchiveManager::loadArchive(const QString &strArchiveFullPath, UiTools::Ass m_pInterface = nullptr; } + qDebug() << "Creating interface for loading"; m_pInterface = UiTools::createInterface(strArchiveFullPath, false, eType); if (m_pInterface) { + qDebug() << "Creating LoadJob"; LoadJob *pLoadJob = new LoadJob(m_pInterface); // 连接槽函数 @@ -133,15 +140,18 @@ bool ArchiveManager::loadArchive(const QString &strArchiveFullPath, UiTools::Ass bool ArchiveManager::addFiles(const QString &strArchiveFullPath, const QList &listAddEntry, const CompressOptions &stOptions) { + qDebug() << "Starting addFiles operation for archive:" << strArchiveFullPath; QJsonObject obj{ {"tid", EventLogUtils::AddCompressFile}, {"operate", "AddCompressFile"}, {"describe", QString("Add File to package: ") + strArchiveFullPath} }; EventLogUtils::get().writeLogs(obj); + qDebug() << "Creating interface for adding files"; m_pTempInterface = UiTools::createInterface(strArchiveFullPath, true); if (m_pTempInterface) { + qDebug() << "Creating AddJob"; AddJob *pAddJob = new AddJob(listAddEntry, m_pTempInterface, stOptions); // 连接槽函数 @@ -153,14 +163,17 @@ bool ArchiveManager::addFiles(const QString &strArchiveFullPath, const QListstart(); + qDebug() << "AddJob started successfully"; return true; } + qWarning() << "Failed to create interface for adding files"; return false; } bool ArchiveManager::extractFiles(const QString &strArchiveFullPath, const QList &files, const ExtractionOptions &stOptions, UiTools::AssignPluginType eType) { + qDebug() << "Starting extractFiles operation for archive:" << strArchiveFullPath; QJsonObject obj{ {"tid", EventLogUtils::ExtractCompressFile}, {"operate", "ExtractCompressFile"}, @@ -168,11 +181,13 @@ bool ArchiveManager::extractFiles(const QString &strArchiveFullPath, const QList }; EventLogUtils::get().writeLogs(obj); if (nullptr == m_pInterface) { + qDebug() << "Creating interface for extraction"; m_pInterface = UiTools::createInterface(strArchiveFullPath, false, eType); } if (m_pInterface) { if (!stOptions.bTar_7z) { + qDebug() << "Creating ExtractJob for regular extraction"; ExtractJob *pExtractJob = new ExtractJob(files, m_pInterface, stOptions); // 连接槽函数 @@ -187,6 +202,7 @@ bool ArchiveManager::extractFiles(const QString &strArchiveFullPath, const QList return pExtractJob->errorcode; } else { + qDebug() << "Creating StepExtractJob for tar.7z archive"; // tar.7z包使用分步解压流程 StepExtractJob *pStepExtractJob = new StepExtractJob(strArchiveFullPath, stOptions/*, strTargetFullPath, strNewArchiveFullPath*/); m_pArchiveJob = pStepExtractJob; @@ -198,10 +214,12 @@ bool ArchiveManager::extractFiles(const QString &strArchiveFullPath, const QList connect(pStepExtractJob, &StepExtractJob::signalQuery, this, &ArchiveManager::signalQuery); pStepExtractJob->start(); + qDebug() << "StepExtractJob started successfully"; return true; } } + qWarning() << "Failed to create interface for extraction"; // 发送结束信号 emit signalJobFinished(ArchiveJob::JT_Extract, PFT_Error, ET_PluginError); return false; @@ -209,6 +227,7 @@ bool ArchiveManager::extractFiles(const QString &strArchiveFullPath, const QList bool ArchiveManager::extractFiles2Path(const QString &strArchiveFullPath, const QList &listSelEntry, const ExtractionOptions &stOptions) { + qDebug() << "Starting extractFiles2Path operation for archive:" << strArchiveFullPath; QJsonObject obj{ {"tid", EventLogUtils::ExtractSingleFile}, {"operate", "ExtractSingleFile"}, @@ -216,10 +235,12 @@ bool ArchiveManager::extractFiles2Path(const QString &strArchiveFullPath, const }; EventLogUtils::get().writeLogs(obj); if (nullptr == m_pInterface) { + qDebug() << "Creating interface for extraction to path"; m_pInterface = UiTools::createInterface(strArchiveFullPath); } if (m_pInterface) { + qDebug() << "Creating ExtractJob for extraction to path"; ExtractJob *pExtractJob = new ExtractJob(listSelEntry, m_pInterface, stOptions); // 连接槽函数 @@ -231,14 +252,17 @@ bool ArchiveManager::extractFiles2Path(const QString &strArchiveFullPath, const m_pArchiveJob = pExtractJob; pExtractJob->start(); + qDebug() << "ExtractJob for extraction to path started successfully"; return true; } + qWarning() << "Failed to create interface for extraction to path"; return false; } bool ArchiveManager::deleteFiles(const QString &strArchiveFullPath, const QList &listSelEntry) { + qDebug() << "Starting deleteFiles operation for archive:" << strArchiveFullPath; QJsonObject obj{ {"tid", EventLogUtils::DelCompressFile}, {"operate", "DelCompressFile"}, @@ -246,10 +270,12 @@ bool ArchiveManager::deleteFiles(const QString &strArchiveFullPath, const QList< }; EventLogUtils::get().writeLogs(obj); if (nullptr == m_pInterface) { + qDebug() << "Creating interface for deletion"; m_pInterface = UiTools::createInterface(strArchiveFullPath); } if (m_pInterface) { + qDebug() << "Creating DeleteJob"; DeleteJob *pDeleteJob = new DeleteJob(listSelEntry, m_pInterface); // 连接槽函数 @@ -261,14 +287,17 @@ bool ArchiveManager::deleteFiles(const QString &strArchiveFullPath, const QList< m_pArchiveJob = pDeleteJob; pDeleteJob->start(); + qDebug() << "DeleteJob started successfully"; return true; } + qWarning() << "Failed to create interface for deletion"; return false; } bool ArchiveManager::renameFiles(const QString &strArchiveFullPath, const QList &listSelEntry) { + qDebug() << "Starting renameFiles operation for archive:" << strArchiveFullPath; QJsonObject obj{ {"tid", EventLogUtils::RenameCompressFile}, {"operate", "RenameCompressFile"}, @@ -276,10 +305,12 @@ bool ArchiveManager::renameFiles(const QString &strArchiveFullPath, const QList< }; EventLogUtils::get().writeLogs(obj); if (nullptr == m_pInterface) { + qDebug() << "Creating interface for renaming"; m_pInterface = UiTools::createInterface(strArchiveFullPath); } if (m_pInterface) { + qDebug() << "Creating RenameJob"; RenameJob *pRenameJob = new RenameJob(listSelEntry, m_pInterface); // 连接槽函数 @@ -291,18 +322,22 @@ bool ArchiveManager::renameFiles(const QString &strArchiveFullPath, const QList< m_pArchiveJob = pRenameJob; pRenameJob->start(); + qDebug() << "RenameJob started successfully"; return true; } + qWarning() << "Failed to create interface for renaming"; return false; } bool ArchiveManager::batchExtractFiles(const QStringList &listFiles, const QString &strTargetPath/*, bool bAutoCreatDir*/) { + qDebug() << "Starting batchExtractFiles operation for" << listFiles.size() << "files"; BatchExtractJob *pBatchExtractJob = new BatchExtractJob(); pBatchExtractJob->setExtractPath(strTargetPath/*, bAutoCreatDir*/); if (pBatchExtractJob->setArchiveFiles(listFiles)) { + qDebug() << "Archive files set successfully for batch extraction"; // 连接槽函数 connect(pBatchExtractJob, &BatchExtractJob::signalJobFinshed, this, &ArchiveManager::slotJobFinished); connect(pBatchExtractJob, &BatchExtractJob::signalprogress, this, &ArchiveManager::signalprogress); @@ -313,15 +348,18 @@ bool ArchiveManager::batchExtractFiles(const QStringList &listFiles, const QStri m_pArchiveJob = pBatchExtractJob; pBatchExtractJob->start(); + qDebug() << "BatchExtractJob started successfully"; return true; } + qWarning() << "Failed to set archive files for batch extraction"; SAFE_DELETE_ELE(pBatchExtractJob); return false; } bool ArchiveManager::openFile(const QString &strArchiveFullPath, const FileEntry &stEntry, const QString &strTempExtractPath, const QString &strProgram) { + qDebug() << "Starting openFile operation for archive:" << strArchiveFullPath; QJsonObject obj{ {"tid", EventLogUtils::OpenCompressFile}, {"operate", "OpenCompressFile"}, @@ -329,10 +367,12 @@ bool ArchiveManager::openFile(const QString &strArchiveFullPath, const FileEntry }; EventLogUtils::get().writeLogs(obj); if (nullptr == m_pInterface) { + qDebug() << "Creating interface for opening file"; m_pInterface = UiTools::createInterface(strArchiveFullPath); } if (m_pInterface) { + qDebug() << "Creating OpenJob"; OpenJob *pOpenJob = new OpenJob(stEntry, strTempExtractPath, strProgram, m_pInterface); // 连接槽函数 @@ -343,15 +383,19 @@ bool ArchiveManager::openFile(const QString &strArchiveFullPath, const FileEntry m_pArchiveJob = pOpenJob; pOpenJob->start(); + qDebug() << "OpenJob started successfully"; return true; } + qWarning() << "Failed to create interface for opening file"; return false; } bool ArchiveManager::updateArchiveCacheData(const UpdateOptions &stOptions) { + qDebug() << "Starting updateArchiveCacheData operation"; if (m_pInterface) { + qDebug() << "Creating UpdateJob"; UpdateJob *pUpdateJob = new UpdateJob(stOptions, m_pInterface); // 连接槽函数 @@ -360,17 +404,21 @@ bool ArchiveManager::updateArchiveCacheData(const UpdateOptions &stOptions) m_pArchiveJob = pUpdateJob; pUpdateJob->start(); + qDebug() << "UpdateJob started successfully"; return true; } + qWarning() << "No interface available for updating archive cache data"; return false; } bool ArchiveManager::updateArchiveComment(const QString &strArchiveFullPath, const QString &strComment) { + qDebug() << "Starting updateArchiveComment operation for archive:" << strArchiveFullPath; ReadOnlyArchiveInterface *pInterface = UiTools::createInterface(strArchiveFullPath, true, UiTools::APT_Libzip); // zip添加注释使用libzipplugin if (pInterface) { + qDebug() << "Creating CommentJob"; CommentJob *pCommentJob = new CommentJob(strComment, pInterface); // 连接槽函数 @@ -380,14 +428,17 @@ bool ArchiveManager::updateArchiveComment(const QString &strArchiveFullPath, con m_pArchiveJob = pCommentJob; pCommentJob->start(); + qDebug() << "CommentJob started successfully"; return true; } + qWarning() << "Failed to create interface for updating archive comment"; return false; } bool ArchiveManager::convertArchive(const QString &strOriginalArchiveFullPath, const QString &strTargetFullPath, const QString &strNewArchiveFullPath) { + qDebug() << "Starting convertArchive operation from:" << strOriginalArchiveFullPath << "to:" << strNewArchiveFullPath; ConvertJob *pConvertJob = new ConvertJob(strOriginalArchiveFullPath, strTargetFullPath, strNewArchiveFullPath); m_pArchiveJob = pConvertJob; @@ -398,37 +449,46 @@ bool ArchiveManager::convertArchive(const QString &strOriginalArchiveFullPath, c connect(pConvertJob, &ConvertJob::signalQuery, this, &ArchiveManager::signalQuery); pConvertJob->start(); + qDebug() << "ConvertJob started successfully"; return true; } bool ArchiveManager::pauseOperation() { + qDebug() << "Attempting to pause current operation"; // 调用job暂停接口 if (m_pArchiveJob) { + qDebug() << "Pausing archive job"; m_pArchiveJob->doPause(); return true; } + qWarning() << "No archive job available to pause"; return false; } bool ArchiveManager::continueOperation() { + qDebug() << "Attempting to continue current operation"; // 调用job继续接口 if (m_pArchiveJob) { + qDebug() << "Continuing archive job"; m_pArchiveJob->doContinue(); return true; } + qWarning() << "No archive job available to continue"; return false; } bool ArchiveManager::cancelOperation() { + qDebug() << "Attempting to cancel current operation"; // 调用job取消接口 if (m_pArchiveJob) { + qDebug() << "Canceling archive job"; m_pArchiveJob->kill(); m_pArchiveJob->deleteLater(); m_pArchiveJob = nullptr; @@ -436,30 +496,36 @@ bool ArchiveManager::cancelOperation() return true; } + qWarning() << "No archive job available to cancel"; return false; } QString ArchiveManager::getCurFilePassword() { + qDebug() << "Getting current file password"; if (m_pInterface) { return m_pInterface->getPassword(); } + qWarning() << "No interface available to get password"; return ""; } bool ArchiveManager::currentStatus() { + qDebug() << "Getting current operation status"; // 调用job状态接口 if (m_pArchiveJob) { return m_pArchiveJob->status(); } + qWarning() << "No archive job available to get status"; return false; } void ArchiveManager::slotJobFinished() { + qDebug() << "slotJobFinished called"; if (m_pArchiveJob) { // 获取结束结果 ArchiveJob::JobType eJobType = m_pArchiveJob->m_eJobType; diff --git a/src/source/archivemanager/batchjob.cpp b/src/source/archivemanager/batchjob.cpp index 12de8385..8846e7b2 100644 --- a/src/source/archivemanager/batchjob.cpp +++ b/src/source/archivemanager/batchjob.cpp @@ -24,69 +24,89 @@ BatchJob::~BatchJob() bool BatchJob::addSubjob(ArchiveJob *job) { + qDebug() << "Adding subjob to BatchJob"; if (nullptr == job || m_listSubjobs.contains(job)) { + qWarning() << "Cannot add subjob - null job or already exists"; return false; } job->setParent(this); m_listSubjobs.append(job); + qDebug() << "Subjob added successfully, total subjobs:" << m_listSubjobs.count(); return true; } bool BatchJob::removeSubjob(ArchiveJob *job) { + qDebug() << "Removing subjob from BatchJob"; if (m_listSubjobs.removeAll(job) > 0) { job->setParent(nullptr); delete job; + qDebug() << "Subjob removed successfully, remaining subjobs:" << m_listSubjobs.count(); return true; } + qWarning() << "Failed to remove subjob - not found"; return false; } bool BatchJob::hasSubjobs() const { + qDebug() << "Checking if BatchJob has subjobs, count:" << m_listSubjobs.count(); return !m_listSubjobs.isEmpty(); } const QList &BatchJob::subjobs() const { + // qDebug() << "Getting subjobs list, count:" << m_listSubjobs.count(); return m_listSubjobs; } void BatchJob::clearSubjobs() { + qDebug() << "Clearing all subjobs, count:" << m_listSubjobs.count(); Q_FOREACH (ArchiveJob *job, m_listSubjobs) { job->setParent(nullptr); delete job; } m_listSubjobs.clear(); + qDebug() << "All subjobs cleared"; } void BatchJob::doPause() { + qDebug() << "Pausing BatchJob"; // 调用子job暂停接口 if (m_pCurJob) { + qDebug() << "Pausing current subjob"; m_pCurJob->doPause(); + } else { + qWarning() << "No current subjob to pause"; } } void BatchJob::doContinue() { + qDebug() << "Continuing BatchJob"; // 调用子job继续接口 if (m_pCurJob) { + qDebug() << "Continuing current subjob"; m_pCurJob->doContinue(); + } else { + qWarning() << "No current subjob to continue"; } } bool BatchJob::status() { + qDebug() << "Getting BatchJob status"; // 调用子job继续接口 if (m_pCurJob) { return m_pCurJob->status(); } + qWarning() << "No current subjob to get status"; return false; } @@ -99,7 +119,7 @@ BatchExtractJob::BatchExtractJob(QObject *parent) BatchExtractJob::~BatchExtractJob() { - + // qDebug() << "BatchExtractJob instance destroyed"; } void BatchExtractJob::start() @@ -151,14 +171,17 @@ bool BatchExtractJob::setArchiveFiles(const QStringList &listFile) bool BatchExtractJob::addExtractItem(const QFileInfo &fileInfo) { + qDebug() << "Adding extract item for file:" << fileInfo.fileName(); QString strName = fileInfo.filePath(); UnCompressParameter::SplitType eType = UnCompressParameter::ST_No; UiTools::transSplitFileName(strName, eType); UiTools::AssignPluginType ePluginType = (UnCompressParameter::ST_Zip == eType) ? (UiTools::AssignPluginType::APT_Cli7z) : (UiTools::AssignPluginType::APT_Auto); + qDebug() << "Creating interface for extract item"; ReadOnlyArchiveInterface *pIface = UiTools::createInterface(fileInfo.filePath(), false, ePluginType); if (pIface) { + qDebug() << "Interface created successfully, setting up extraction options"; // 创建解压参数 ExtractionOptions stOptions; stOptions.strTargetPath = m_strExtractPath; @@ -187,12 +210,14 @@ bool BatchExtractJob::addExtractItem(const QFileInfo &fileInfo) // tar.7z特殊处理,右键解压缩到当前文件夹使用cli7zplugin if (strName.endsWith(QLatin1String(".tar.7z")) && determineMimeType(strName).name() == QLatin1String("application/x-7z-compressed")) { + qDebug() << "Detected tar.7z archive, using special handling"; stOptions.bTar_7z = true; ePluginType = UiTools::AssignPluginType::APT_Cli7z; } pIface->setParent(this); // 跟随BatchExtractJob释放 if (!stOptions.bTar_7z) { + qDebug() << "Creating ExtractJob for regular archive"; ExtractJob *pExtractJob = new ExtractJob(QList(), pIface, stOptions); connect(pExtractJob, &ExtractJob::signalprogress, this, &BatchExtractJob::slotHandleSingleJobProgress); connect(pExtractJob, &ExtractJob::signalCurFileName, this, &BatchExtractJob::slotHandleSingleJobCurFileName); @@ -200,6 +225,7 @@ bool BatchExtractJob::addExtractItem(const QFileInfo &fileInfo) connect(pExtractJob, &ExtractJob::signalJobFinshed, this, &BatchExtractJob::slotHandleSingleJobFinished); addSubjob(pExtractJob); } else { + qDebug() << "Creating StepExtractJob for tar.7z archive"; StepExtractJob *pStepExtractJob = new StepExtractJob(fileInfo.absoluteFilePath(), stOptions); connect(pStepExtractJob, &StepExtractJob::signalprogress, this, &BatchExtractJob::slotHandleSingleJobProgress); connect(pStepExtractJob, &StepExtractJob::signalCurFileName, this, &BatchExtractJob::slotHandleSingleJobCurFileName); @@ -207,9 +233,11 @@ bool BatchExtractJob::addExtractItem(const QFileInfo &fileInfo) connect(pStepExtractJob, &StepExtractJob::signalJobFinshed, this, &BatchExtractJob::slotHandleSingleJobFinished); addSubjob(pStepExtractJob); } + qDebug() << "Extract item added successfully"; return true; } + qWarning() << "Failed to create interface for extract item"; return false; } @@ -218,16 +246,19 @@ void BatchExtractJob::slotHandleSingleJobProgress(double dPercentage) QFileInfo fileInfo(m_listFiles[m_iCurArchiveIndex]); qint64 qCurSize = fileInfo.size(); // 当前解压的压缩包大小 double dProgress = double(qCurSize) * dPercentage / m_qBatchTotalSize + m_dLastPercentage; + qDebug() << "Batch job progress:" << dProgress << "%, current file:" << fileInfo.fileName(); emit signalprogress(dProgress); } void BatchExtractJob::slotHandleSingleJobCurFileName(const QString &strName) { + qDebug() << "Current file being processed:" << strName; emit signalCurFileName(strName); } void BatchExtractJob::slotHandleSingleJobFinished() { + qDebug() << "Single job finished handler called"; if (m_pCurJob != nullptr) { qDebug() << "Single job finished - Type:" << m_pCurJob->m_eJobType << "Result:" << m_pCurJob->m_eFinishedType; @@ -245,6 +276,7 @@ void BatchExtractJob::slotHandleSingleJobFinished() } // 移除当前job + qDebug() << "Removing completed subjob"; removeSubjob(m_pCurJob); if (!hasSubjobs()) { @@ -263,5 +295,7 @@ void BatchExtractJob::slotHandleSingleJobFinished() m_pCurJob = subjobs().at(0); m_pCurJob->start(); } + } else { + qWarning() << "No current job to handle"; } } diff --git a/src/source/archivemanager/singlejob.cpp b/src/source/archivemanager/singlejob.cpp index 375bd0ac..22cdffea 100644 --- a/src/source/archivemanager/singlejob.cpp +++ b/src/source/archivemanager/singlejob.cpp @@ -18,6 +18,7 @@ // 工作线程 void SingleJobThread::run() { + // qDebug() << "SingleJobThread started"; q->doWork(); // 在线程中执行操作 } @@ -259,12 +260,15 @@ void CreateJob::doWork() bool CreateJob::doKill() { + qDebug() << "CreateJob doKill"; if (nullptr == m_pInterface) { + qDebug() << "CreateJob doKill, interface is null"; return false; } const bool killed = m_pInterface->doKill(); if (killed) { + qDebug() << "CreateJob doKill, interface killed"; cleanCompressFileCancel(); return true; } @@ -280,7 +284,9 @@ bool CreateJob::doKill() void CreateJob::cleanCompressFileCancel() { + qDebug() << "CreateJob cleanCompressFileCancel"; if (m_stCompressOptions.bSplit) { + qDebug() << "CreateJob cleanCompressFileCancel, split compress"; // 判断 7z分卷压缩的 文件名 QFileInfo file(dynamic_cast(m_pInterface)->getArchiveName()); QStringList nameFilters; @@ -296,6 +302,7 @@ void CreateJob::cleanCompressFileCancel() } } } else { + qDebug() << "CreateJob cleanCompressFileCancel, not split compress"; QFile fiRemove(dynamic_cast(m_pInterface)->getArchiveName()); // 没有判断 7z分卷压缩的 文件名 if (fiRemove.exists()) { qInfo() << "取消时删除:" << fiRemove.fileName(); @@ -310,13 +317,14 @@ ExtractJob::ExtractJob(const QList &files, ReadOnlyArchiveInterface * , m_vecFiles(files) , m_stExtractionOptions(options) { + qDebug() << "ExtractJob constructor"; initConnections(); m_eJobType = JT_Extract; } ExtractJob::~ExtractJob() { - + qDebug() << "ExtractJob instance destroyed"; } void ExtractJob::doWork() @@ -345,6 +353,7 @@ DeleteJob::DeleteJob(const QList &files, ReadOnlyArchiveInterface *pI : SingleJob(pInterface, parent) , m_vecFiles(files) { + qDebug() << "DeleteJob constructor"; m_eJobType = JT_Delete; initConnections(); m_eJobType = JT_Delete; @@ -352,20 +361,23 @@ DeleteJob::DeleteJob(const QList &files, ReadOnlyArchiveInterface *pI DeleteJob::~DeleteJob() { - + qDebug() << "DeleteJob instance destroyed"; } void DeleteJob::doWork() { + qDebug() << "DeleteJob starting work, files count:" << m_vecFiles.size(); ReadWriteArchiveInterface *pWriteInterface = dynamic_cast(m_pInterface); if (nullptr == pWriteInterface) { + qWarning() << "Failed to cast to ReadWriteArchiveInterface in DeleteJob"; return; } PluginFinishType eType = pWriteInterface->deleteFiles(m_vecFiles); if (!(pWriteInterface->waitForFinished())) { + qDebug() << "Emitting finished signal"; slotFinished(eType); } } @@ -375,27 +387,34 @@ RenameJob::RenameJob(const QList &files, ReadOnlyArchiveInterface *pI : SingleJob(pInterface, parent) , m_vecFiles(files) { + qDebug() << "RenameJob constructor"; initConnections(); m_eJobType = JT_Rename; } RenameJob::~RenameJob() { - + qDebug() << "RenameJob instance destroyed"; } void RenameJob::doWork() { + qDebug() << "RenameJob starting work, files count:" << m_vecFiles.size(); ReadWriteArchiveInterface *pWriteInterface = dynamic_cast(m_pInterface); if (nullptr == pWriteInterface) { + qWarning() << "Failed to cast to ReadWriteArchiveInterface in RenameJob"; return; } PluginFinishType eType = pWriteInterface->renameFiles(m_vecFiles); + qDebug() << "Rename operation completed, result:" << eType; if (!(pWriteInterface->waitForFinished())) { + qDebug() << "Emitting finished signal"; slotFinished(eType); + } else { + qDebug() << "Rename operation completed synchronously"; } } @@ -405,6 +424,7 @@ OpenJob::OpenJob(const FileEntry &stEntry, const QString &strTempExtractPath, co , m_strTempExtractPath(strTempExtractPath) , m_strProgram(strProgram) { + qDebug() << "OpenJob instance created for file:" << stEntry.strFileName; m_eJobType = JT_Open; connect(m_pInterface, &ReadOnlyArchiveInterface::signalFinished, this, &OpenJob::slotFinished, Qt::ConnectionType::UniqueConnection); connect(m_pInterface, &ReadOnlyArchiveInterface::signalQuery, this, &SingleJob::signalQuery, Qt::ConnectionType::AutoConnection); @@ -412,11 +432,12 @@ OpenJob::OpenJob(const FileEntry &stEntry, const QString &strTempExtractPath, co OpenJob::~OpenJob() { - + qDebug() << "OpenJob instance destroyed"; } void OpenJob::doWork() { + qDebug() << "OpenJob starting work for file:" << m_stEntry.strFileName; if (m_pInterface) { // 构建解压参数 ExtractionOptions options; @@ -424,6 +445,7 @@ void OpenJob::doWork() options.strTargetPath = m_strTempExtractPath; // 当作提取,去除父目录 if (m_stEntry.strFullPath.contains(QDir::separator())) { + qDebug() << "Setting destination for nested file"; int iIndex = m_stEntry.strFullPath.lastIndexOf(QDir::separator()); if (iIndex > 0) options.strDestination = m_stEntry.strFullPath.left(iIndex + 1); // 当前路径截掉最后一级目录(保留'/') @@ -431,42 +453,53 @@ void OpenJob::doWork() options.qSize = m_stEntry.qSize; PluginFinishType eType = m_pInterface->extractFiles(QList() << m_stEntry, options); + qDebug() << "Open extraction operation completed, result:" << eType; if (!(m_pInterface->waitForFinished())) { + qDebug() << "Emitting finished signal"; slotFinished(eType); + } else { + qDebug() << "Open extraction completed synchronously"; } + } else { + qWarning() << "Interface is null in OpenJob"; } } void OpenJob::slotFinished(PluginFinishType eType) { + qDebug() << "OpenJob finished with type:" << eType; if (PFT_Nomral == eType) { + qDebug() << "Processing file for opening"; QString name = m_stEntry.strFileName; //对于超长文件打开失败问题处理 QString strTempFileName = m_stEntry.strFileName; if (NAME_MAX < QString(strTempFileName).toLocal8Bit().length() && !strTempFileName.endsWith(QDir::separator())) { + qDebug() << "Handling long filename"; QString strTemp = strTempFileName.left(60); name = strTemp + QString("(%1)").arg(1, 3, 10, QChar('0'))+"." + QFileInfo(strTempFileName).completeSuffix(); } if (name.contains("%")) { // 文件名含有%的时候无法直接双击打开, 创建一个该文件的链接,文件名不含有%,通过打开链接打开源文件 + qDebug() << "Creating link for file with % in name"; name = m_strTempExtractPath + QDir::separator() + name.replace("%", "1"); // 将文件名中的%替换为1; if (!QFile::link(m_stEntry.strFileName, name)) { // 创建链接 + qWarning() << "Failed to create link for file"; return; } } else { name = m_strTempExtractPath + QDir::separator() + name; } - - - // 在线程中执行外部应用打开的命令 + qDebug() << "Starting external process to open file:" << name; ProcessOpenThread *p = new ProcessOpenThread; p->setProgramPath(OpenWithDialog::getProgramPathByExec(m_strProgram)); p->setArguments(QStringList() << name); p->start(); + } else { + qWarning() << "Failed to open file, type:" << eType; } SingleJob::slotFinished(eType); // 在结束上述操作之后发送job结束信号 @@ -476,21 +509,24 @@ UpdateJob::UpdateJob(const UpdateOptions &options, ReadOnlyArchiveInterface *pIn : SingleJob(pInterface, parent) , m_stOptions(options) { + qDebug() << "UpdateJob instance created"; m_eJobType = JT_Update; //connect(m_pInterface, &ReadOnlyArchiveInterface::signalFinished, this, &UpdateJob::slotFinished, Qt::ConnectionType::UniqueConnection); } UpdateJob::~UpdateJob() { - + qDebug() << "UpdateJob instance destroyed"; } void UpdateJob::start() { + qDebug() << "Starting UpdateJob"; jobTimer.start(); // 若插件指针为空,立即异常退出 if (nullptr == m_pInterface) { + qWarning() << "Interface is null in UpdateJob"; slotFinished(PFT_Error); return; } @@ -500,15 +536,20 @@ void UpdateJob::start() void UpdateJob::doWork() { + qDebug() << "UpdateJob starting work"; ReadWriteArchiveInterface *pWriteInterface = dynamic_cast(m_pInterface); if (pWriteInterface) { + qDebug() << "Calling updateArchiveData"; // 调用更新函数 PluginFinishType eType = pWriteInterface->updateArchiveData(m_stOptions); + qDebug() << "Update operation completed, result:" << eType; //if (!(pWriteInterface->waitForFinished())) { slotFinished(eType); //} + } else { + qWarning() << "Failed to cast to ReadWriteArchiveInterface in UpdateJob"; } } @@ -516,6 +557,7 @@ CommentJob::CommentJob(const QString &strComment, ReadOnlyArchiveInterface *pInt : SingleJob(pInterface, parent) , m_strComment(strComment) { + qDebug() << "CommentJob instance created with comment length:" << strComment.length(); m_eJobType = JT_Comment; // 进度和结束处理 @@ -525,6 +567,7 @@ CommentJob::CommentJob(const QString &strComment, ReadOnlyArchiveInterface *pInt CommentJob::~CommentJob() { + qDebug() << "CommentJob instance destroyed"; if (m_pInterface) { delete m_pInterface; m_pInterface = nullptr; @@ -533,15 +576,22 @@ CommentJob::~CommentJob() void CommentJob::doWork() { + qDebug() << "CommentJob starting work"; qInfo() << "Adding comment"; ReadWriteArchiveInterface *pWriteInterface = dynamic_cast(m_pInterface); if (pWriteInterface) { PluginFinishType eType = pWriteInterface->addComment(m_strComment); + qDebug() << "Add comment operation completed, result:" << eType; if (!(pWriteInterface->waitForFinished())) { + qDebug() << "Emitting finished signal"; slotFinished(eType); + } else { + qDebug() << "Comment operation completed synchronously"; } + } else { + qWarning() << "Failed to cast to ReadWriteArchiveInterface in CommentJob"; } } @@ -549,11 +599,12 @@ ComplexJob::ComplexJob(const QString strOriginalArchiveFullPath, QObject *parent : ArchiveJob(parent) , m_strOriginalArchiveFullPath(strOriginalArchiveFullPath) { - + qDebug() << "ComplexJob instance created for:" << strOriginalArchiveFullPath; } ComplexJob::~ComplexJob() { + qDebug() << "ComplexJob instance destroyed"; if (m_pIface) { delete m_pIface; m_pIface = nullptr; @@ -562,36 +613,52 @@ ComplexJob::~ComplexJob() void ComplexJob::doPause() { + qDebug() << "Pausing ComplexJob"; // 调用插件暂停接口 if (m_pIface) { + qDebug() << "Calling interface pause operation"; m_pIface->pauseOperation(); + } else { + qWarning() << "Interface is null, cannot pause"; } } void ComplexJob::doContinue() { + qDebug() << "Continuing ComplexJob"; // 调用插件继续接口 if (m_pIface) { + qDebug() << "Calling interface continue operation"; m_pIface->continueOperation(); + } else { + qWarning() << "Interface is null, cannot continue"; } } bool ComplexJob::doKill() { - return m_pIface->doKill(); + qDebug() << "Killing ComplexJob"; + if (m_pIface) { + return m_pIface->doKill(); + } + qWarning() << "Interface is null, cannot kill"; + return false; } void ComplexJob::slotHandleSingleJobProgress(double dPercentage) { if (0 == m_iStepNo) { // 解压进度 + qDebug() << "Extract step progress:" << dPercentage; emit signalprogress(dPercentage * 0.3); } else { // 压缩进度 + qDebug() << "Compress step progress:" << dPercentage; emit signalprogress(30 + dPercentage * 0.7); } } void ComplexJob::slotHandleSingleJobCurFileName(const QString &strName) { + qDebug() << "Current file in complex job:" << strName; emit signalCurFileName(strName); } @@ -600,17 +667,20 @@ ConvertJob::ConvertJob(const QString strOriginalArchiveFullPath, const QString s , m_strTargetFullPath(strTargetFullPath) , m_strNewArchiveFullPath(strNewArchiveFullPath) { + qDebug() << "ConvertJob instance created from:" << strOriginalArchiveFullPath << "to:" << strNewArchiveFullPath; m_eJobType = JT_Convert; } ConvertJob::~ConvertJob() { + qDebug() << "ConvertJob instance destroyed"; SAFE_DELETE_ELE(m_pCreateJob) SAFE_DELETE_ELE(m_pExtractJob); } void ConvertJob::start() { + qDebug() << "Starting ConvertJob"; ReadOnlyArchiveInterface *pIface = UiTools::createInterface(m_strOriginalArchiveFullPath); if (pIface) { @@ -626,6 +696,7 @@ void ConvertJob::start() stOptions.bAllExtract = true; // 创建解压操作 + qDebug() << "Creating ExtractJob for conversion"; m_pExtractJob = new ExtractJob(QList(), pIface, stOptions); connect(m_pExtractJob, &ExtractJob::signalprogress, this, &ConvertJob::slotHandleSingleJobProgress); connect(m_pExtractJob, &ExtractJob::signalCurFileName, this, &ConvertJob::slotHandleSingleJobCurFileName); @@ -633,15 +704,19 @@ void ConvertJob::start() connect(m_pExtractJob, &ExtractJob::signalJobFinshed, this, &ConvertJob::slotHandleExtractFinished); m_pExtractJob->doWork(); + } else { + qWarning() << "Failed to create interface for conversion"; } } void ConvertJob::slotHandleExtractFinished() { + qDebug() << "Extract step finished in ConvertJob"; // 解压结束 if (m_pExtractJob) { m_eFinishedType = m_pExtractJob->m_eFinishedType; m_eErrorType = m_pExtractJob->m_eErrorType; + qDebug() << "Extract finished with type:" << m_eFinishedType; switch (m_eFinishedType) { // 正常结束之后,进行压缩操作 @@ -652,6 +727,7 @@ void ConvertJob::slotHandleExtractFinished() ReadOnlyArchiveInterface *pIface = UiTools::createInterface(m_strNewArchiveFullPath, true); if (pIface) { + qDebug() << "Creating interface for compression step"; SAFE_DELETE_ELE(m_pIface); m_pIface = pIface; QList listEntry; @@ -661,6 +737,7 @@ void ConvertJob::slotHandleExtractFinished() | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Hidden); + qDebug() << "Found" << fileList.size() << "files to compress"; foreach (QFileInfo strFile, fileList) { FileEntry stFileEntry; stFileEntry.strFullPath = strFile.filePath(); @@ -673,12 +750,15 @@ void ConvertJob::slotHandleExtractFinished() options.qTotalSize = DataManager::get_instance().archiveData().qSize; // list压缩包时存储的压缩包内文件实际总大小 // 创建压缩操作 + qDebug() << "Creating CreateJob for compression"; m_pCreateJob = new CreateJob(listEntry, pIface, options); connect(m_pCreateJob, &CreateJob::signalprogress, this, &ConvertJob::slotHandleSingleJobProgress); connect(m_pCreateJob, &CreateJob::signalCurFileName, this, &ConvertJob::slotHandleSingleJobCurFileName); connect(m_pCreateJob, &CreateJob::signalJobFinshed, this, &ConvertJob::signalJobFinshed); m_pCreateJob->doWork(); + } else { + qWarning() << "Failed to create interface for compression step"; } } break; @@ -695,6 +775,8 @@ void ConvertJob::slotHandleExtractFinished() } break; } + } else { + qWarning() << "No extract job to handle"; } } @@ -702,16 +784,18 @@ StepExtractJob::StepExtractJob(const QString strOriginalArchiveFullPath, const E : ComplexJob(strOriginalArchiveFullPath, parent) , m_stExtractionOptions(stOptions) { + qDebug() << "StepExtractJob instance created for:" << strOriginalArchiveFullPath; m_eJobType = JT_StepExtract; } StepExtractJob::~StepExtractJob() { - + qDebug() << "StepExtractJob instance destroyed"; } void StepExtractJob::start() { + qDebug() << "Starting StepExtractJob"; // tar.7z 指定使用cli7zplugin先解压出tar包 ReadOnlyArchiveInterface *pIface = UiTools::createInterface(m_strOriginalArchiveFullPath, false); @@ -726,6 +810,7 @@ void StepExtractJob::start() m_strTempFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QDir::separator() + strProcessID + QDir::separator() + QUuid::createUuid().toString(QUuid::Id128); + qDebug() << "Temp extraction path:" << m_strTempFilePath; // 创建解压参数 ExtractionOptions stOptions; stOptions.strTargetPath = m_strTempFilePath; @@ -733,6 +818,7 @@ void StepExtractJob::start() stOptions.bAllExtract = true; // 创建解压操作 + qDebug() << "Creating first ExtractJob for tar.7z"; m_pExtractJob = new ExtractJob(QList(), pIface, stOptions, this); connect(m_pExtractJob, &ExtractJob::signalprogress, this, &StepExtractJob::slotHandleSingleJobProgress); connect(m_pExtractJob, &ExtractJob::signalCurFileName, this, &StepExtractJob::slotHandleSingleJobCurFileName); @@ -740,26 +826,33 @@ void StepExtractJob::start() connect(m_pExtractJob, &ExtractJob::signalJobFinshed, this, &StepExtractJob::slotHandleExtractFinished); m_pExtractJob->start(); + } else { + qWarning() << "Failed to create interface for StepExtractJob"; } } void StepExtractJob::slotHandleExtractFinished() { + qDebug() << "Step extract finished handler called"; // 解压结束 if (nullptr != m_pExtractJob) { m_eFinishedType = m_pExtractJob->m_eFinishedType; m_eErrorType = m_pExtractJob->m_eErrorType; + qDebug() << "Extract finished with type:" << m_eFinishedType; switch (m_eFinishedType) { // 正常结束之后,进行压缩操作 case PFT_Nomral: { + qDebug() << "Extract completed successfully, checking temp files"; // 获取临时解压文件 QDir dir(m_strTempFilePath); if (!dir.exists()) { + qWarning() << "Temp directory does not exist"; return; } QFileInfoList list = dir.entryInfoList(QDir::AllEntries | QDir::System | QDir::NoDotAndDotDot | QDir::Hidden); + qDebug() << "Found" << list.count() << "files in temp directory"; /***tar.7z格式压缩流程特殊处理*** * 1、tar.7z本质上就是一个tar包压缩成7z包,类型依然是x-7z-compressed @@ -770,6 +863,7 @@ void StepExtractJob::slotHandleExtractFinished() if (1 == list.count() && list.at(0).filePath().endsWith(".tar") && determineMimeType(list.at(0).filePath()).name() == QLatin1String("application/x-tar")) { + qDebug() << "Found single tar file, proceeding with special handling"; QFileInfo fileInfo = list.at(0); ReadOnlyArchiveInterface *pIface = UiTools::createInterface(fileInfo.absoluteFilePath(), false); @@ -788,6 +882,7 @@ void StepExtractJob::slotHandleExtractFinished() stOptions.bTar_7z = false; // 创建解压操作 + qDebug() << "Creating second ExtractJob for tar file"; m_pExtractJob2 = new ExtractJob(QList(), pIface, stOptions, this); connect(m_pExtractJob2, &ExtractJob::signalprogress, this, &StepExtractJob::slotHandleSingleJobProgress); connect(m_pExtractJob2, &ExtractJob::signalCurFileName, this, &StepExtractJob::slotHandleSingleJobCurFileName); @@ -795,8 +890,11 @@ void StepExtractJob::slotHandleExtractFinished() connect(m_pExtractJob2, &ExtractJob::signalJobFinshed, this, &StepExtractJob::signalJobFinshed); m_pExtractJob2->start(); + } else { + qWarning() << "Failed to create interface for tar file"; } } else { + qDebug() << "Using fallback extraction method"; ReadOnlyArchiveInterface *pIface = UiTools::createInterface(m_strOriginalArchiveFullPath, false); if (nullptr != pIface) { @@ -812,6 +910,7 @@ void StepExtractJob::slotHandleExtractFinished() stOptions.bTar_7z = false; // 创建解压操作 + qDebug() << "Creating fallback ExtractJob"; m_pExtractJob2 = new ExtractJob(QList(), pIface, stOptions, this); connect(m_pExtractJob2, &ExtractJob::signalprogress, this, &StepExtractJob::slotHandleSingleJobProgress); connect(m_pExtractJob2, &ExtractJob::signalCurFileName, this, &StepExtractJob::slotHandleSingleJobCurFileName); @@ -819,31 +918,41 @@ void StepExtractJob::slotHandleExtractFinished() connect(m_pExtractJob2, &ExtractJob::signalJobFinshed, this, &StepExtractJob::signalJobFinshed); m_pExtractJob2->start(); + } else { + qWarning() << "Failed to create interface for fallback extraction"; } } } break; // 用户取消之后,不进行压缩 case PFT_Cancel: { + qInfo() << "Step extract cancelled"; emit signalJobFinshed(); } break; // 出现错误的情况,提示用户 case PFT_Error: { + qInfo() << "Step extract error"; emit signalJobFinshed(); } break; } + } else { + qWarning() << "No extract job to handle"; } } bool StepExtractJob::doKill() { - const bool killed = m_pIface->doKill(); - if (killed) { - return true; + qDebug() << "Killing StepExtractJob"; + if (m_pIface) { + const bool killed = m_pIface->doKill(); + if (killed) { + qDebug() << "StepExtractJob killed successfully"; + return true; + } } - if (m_pExtractJob2->getdptr()->isRunning()) { //Returns true if the thread is running + if (m_pExtractJob2 && m_pExtractJob2->getdptr()->isRunning()) { //Returns true if the thread is running qInfo() << "Requesting graceful thread interruption, will abort in one second otherwise."; m_pExtractJob2->getdptr()->requestInterruption(); //请求中断线程(建议性) m_pExtractJob2->getdptr()->wait(1000); //阻塞1s或阻塞到线程结束(取小) diff --git a/src/source/common/calculatesizethread.cpp b/src/source/common/calculatesizethread.cpp index d4f01a7e..731c47fe 100644 --- a/src/source/common/calculatesizethread.cpp +++ b/src/source/common/calculatesizethread.cpp @@ -28,6 +28,7 @@ CalculateSizeThread::CalculateSizeThread(const QStringList &listfiles, const QSt void CalculateSizeThread::set_thread_stop(bool thread_stop) { + qInfo() << "set_thread_stop:" << thread_stop; m_thread_stop = thread_stop; } diff --git a/src/source/common/customwidget.cpp b/src/source/common/customwidget.cpp index a1454cab..7b937f22 100644 --- a/src/source/common/customwidget.cpp +++ b/src/source/common/customwidget.cpp @@ -30,7 +30,7 @@ CustomSuggestButton::CustomSuggestButton(const QString &text, QWidget *parent) void CustomSuggestButton::keyPressEvent(QKeyEvent *event) { - qDebug() << "Key press event, key:" << event->key(); + // qDebug() << "Key press event, key:" << event->key(); if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行按下按钮 // 模拟空格键按下事件 QKeyEvent pressSpace(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier, " "); @@ -42,7 +42,7 @@ void CustomSuggestButton::keyPressEvent(QKeyEvent *event) void CustomSuggestButton::keyReleaseEvent(QKeyEvent *event) { - qDebug() << "Key release event, key:" << event->key(); + // qDebug() << "Key release event, key:" << event->key(); if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行弹起按钮 // 模拟空格键松开事件 QKeyEvent releaseSpace(QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier, " "); @@ -60,7 +60,7 @@ CustomCombobox::CustomCombobox(QWidget *parent): DComboBox(parent) void CustomCombobox::keyPressEvent(QKeyEvent *event) { - qDebug() << "ComboBox key press event, key:" << event->key(); + // qDebug() << "ComboBox key press event, key:" << event->key(); if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行打开下拉列表功能 // 模拟空格键按下事件 QKeyEvent pressSpace(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier, " "); @@ -72,7 +72,7 @@ void CustomCombobox::keyPressEvent(QKeyEvent *event) void CustomCombobox::keyReleaseEvent(QKeyEvent *event) { - qDebug() << "ComboBox key release event, key:" << event->key(); + // qDebug() << "ComboBox key release event, key:" << event->key(); if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行打开下拉列表功能 // 模拟空格键松开事件 QKeyEvent releaseSpace(QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier, " "); @@ -88,6 +88,7 @@ void CustomCombobox::keyReleaseEvent(QKeyEvent *event) */ void CustomCombobox::paintEvent(QPaintEvent *event) { + // qDebug() << "ComboBox paint event"; DComboBox::paintEvent(event); if (hasFocus() && (m_reson & (Qt::TabFocusReason | Qt::BacktabFocusReason))) { DStylePainter painter(this); @@ -149,7 +150,7 @@ CustomPushButton::CustomPushButton(const QIcon &icon, const QString &text, QWidg void CustomPushButton::keyPressEvent(QKeyEvent *event) { - qDebug() << "PushButton key press event, key:" << event->key(); + // qDebug() << "PushButton key press event, key:" << event->key(); if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行按下按钮 // 模拟空格键按下事件 QKeyEvent pressSpace(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier, " "); @@ -161,7 +162,7 @@ void CustomPushButton::keyPressEvent(QKeyEvent *event) void CustomPushButton::keyReleaseEvent(QKeyEvent *event) { - qDebug() << "PushButton key release event, key:" << event->key(); + // qDebug() << "PushButton key release event, key:" << event->key(); if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行弹起按钮 // 模拟空格键松开事件 QKeyEvent releaseSpace(QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier, " "); @@ -174,12 +175,15 @@ void CustomPushButton::keyReleaseEvent(QKeyEvent *event) CustomSwitchButton::CustomSwitchButton(QWidget *parent) : DSwitchButton(parent) { + qDebug() << "CustomSwitchButton initialized"; setFocusPolicy(Qt::TabFocus); } void CustomSwitchButton::keyPressEvent(QKeyEvent *event) { + // qDebug() << "CustomSwitchButton::keyPressEvent" << event; if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行打开下拉列表功能 + qDebug() << "CustomSwitchButton::keyPressEvent press enter"; // 模拟空格键按下事件 QKeyEvent pressSpace(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier, " "); QApplication::sendEvent(this, &pressSpace); @@ -195,8 +199,10 @@ void CustomSwitchButton::keyPressEvent(QKeyEvent *event) void CustomSwitchButton::paintEvent(QPaintEvent *event) { + // qDebug() << "CustomSwitchButton::paintEvent" << event; DSwitchButton::paintEvent(event); if (hasFocus() && (m_reson & (Qt::TabFocusReason | Qt::BacktabFocusReason))) { + // qDebug() << "CustomSwitchButton::paintEvent has focus"; DStylePainter painter(this); // painter.setPen(palette().color(QPalette::Text)); DStyle *style = dynamic_cast(DApplication::style()); @@ -229,6 +235,7 @@ void CustomSwitchButton::paintEvent(QPaintEvent *event) void CustomSwitchButton::focusInEvent(QFocusEvent *event) { + // qDebug() << "CustomSwitchButton::focusInEvent" << event; // m_reson = event->reason(); //不使用自绘的焦点效果,注释掉 DSwitchButton::focusInEvent(event); } @@ -236,18 +243,20 @@ void CustomSwitchButton::focusInEvent(QFocusEvent *event) CustomCheckBox::CustomCheckBox(QWidget *parent) : DCheckBox(parent) { - + qDebug() << "CustomCheckBox::CustomCheckBox"; } CustomCheckBox::CustomCheckBox(const QString &text, QWidget *parent) : DCheckBox(text, parent) { - + qDebug() << "CustomCheckBox::CustomCheckBox" << text; } void CustomCheckBox::keyPressEvent(QKeyEvent *event) { + // qDebug() << "CustomCheckBox::keyPressEvent" << event; if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行切换状态 + qDebug() << "CustomCheckBox::keyPressEvent press enter"; // 模拟空格键按下事件 QKeyEvent pressSpace(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier, " "); QApplication::sendEvent(this, &pressSpace); @@ -258,7 +267,9 @@ void CustomCheckBox::keyPressEvent(QKeyEvent *event) void CustomCheckBox::keyReleaseEvent(QKeyEvent *event) { + // qDebug() << "CustomCheckBox::keyReleaseEvent" << event; if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行切换状态 + qDebug() << "CustomCheckBox::keyReleaseEvent press enter"; // 模拟空格键松开事件 QKeyEvent releaseSpace(QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier, " "); QApplication::sendEvent(this, &releaseSpace); @@ -270,12 +281,14 @@ void CustomCheckBox::keyReleaseEvent(QKeyEvent *event) CustomCommandLinkButton::CustomCommandLinkButton(const QString text, QWidget *parent) : DCommandLinkButton(text, parent) { - + qDebug() << "CustomCommandLinkButton::CustomCommandLinkButton" << text; } void CustomCommandLinkButton::keyPressEvent(QKeyEvent *event) { + // qDebug() << "CustomCommandLinkButton::keyPressEvent" << event; if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行切换状态 + qDebug() << "CustomCommandLinkButton::keyPressEvent press enter"; // 模拟空格键按下事件 QKeyEvent pressSpace(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier, " "); QApplication::sendEvent(this, &pressSpace); @@ -286,7 +299,9 @@ void CustomCommandLinkButton::keyPressEvent(QKeyEvent *event) void CustomCommandLinkButton::keyReleaseEvent(QKeyEvent *event) { + // qDebug() << "CustomCommandLinkButton::keyReleaseEvent" << event; if (Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) { //“回车键” 执行切换状态 + qDebug() << "CustomCommandLinkButton::keyReleaseEvent press enter"; // 模拟空格键松开事件 QKeyEvent releaseSpace(QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier, " "); QApplication::sendEvent(this, &releaseSpace); @@ -299,6 +314,7 @@ CustomFloatingMessage::CustomFloatingMessage(const QIcon &ico, const QString &st QWidget *parent, MessageType notifyType) : DFloatingMessage(notifyType, parent) { + qDebug() << "CustomFloatingMessage::CustomFloatingMessage" << str << msec; setIcon(ico); setMessage(str); setDuration(msec); diff --git a/src/source/common/ddesktopservicesthread.cpp b/src/source/common/ddesktopservicesthread.cpp index 676d1436..a8f1c985 100644 --- a/src/source/common/ddesktopservicesthread.cpp +++ b/src/source/common/ddesktopservicesthread.cpp @@ -26,6 +26,7 @@ void DDesktopServicesThread::setOpenFiles(const QStringList &listFiles) bool DDesktopServicesThread::hasFiles() { + // qInfo() << "Check if there are files to open, count:" << m_listFiles.size(); return !m_listFiles.isEmpty(); } diff --git a/src/source/common/mimetypedisplaymanager.cpp b/src/source/common/mimetypedisplaymanager.cpp index 7b955c9b..294675b1 100644 --- a/src/source/common/mimetypedisplaymanager.cpp +++ b/src/source/common/mimetypedisplaymanager.cpp @@ -56,11 +56,12 @@ void MimeTypeDisplayManager::initData() void MimeTypeDisplayManager::initConnect() { - + qDebug() << "Initializing connections"; } QString MimeTypeDisplayManager::displayName(const QString &mimeType) { + qDebug() << "Getting display name for MIME type:" << mimeType; return m_displayNames.value(displayNameToEnum(mimeType)); } @@ -68,35 +69,47 @@ FileType MimeTypeDisplayManager::displayNameToEnum(const QString &mimeType) { qDebug() << "Converting MIME type to enum:" << mimeType; if (mimeType == "application/x-desktop") { + qDebug() << "Identified as DesktopApplication"; return FileType::DesktopApplication; } else if (mimeType == "inode/directory") { + qDebug() << "Identified as Directory"; return FileType::Directory; } else if (mimeType == "application/x-executable" || ExecutableMimeTypes.contains(mimeType)) { + qDebug() << "Identified as Executable"; return FileType::Executable; } else if (mimeType.startsWith("video/") || VideoMimeTypes.contains(mimeType)) { + qDebug() << "Identified as Video"; return FileType::Videos; } else if (mimeType.startsWith("audio/") || AudioMimeTypes.contains(mimeType)) { + qDebug() << "Identified as Audio"; return FileType::Audios; } else if (mimeType.startsWith("image/") || ImageMimeTypes.contains(mimeType)) { + qDebug() << "Identified as Image"; return FileType::Images; } else if (mimeType.startsWith("text/") || TextMimeTypes.contains(mimeType)) { + qDebug() << "Identified as Document"; return FileType::Documents; } else if (ArchiveMimeTypes.contains(mimeType)) { + qDebug() << "Identified as Archive"; return FileType::Archives; } else if (BackupMimeTypes.contains(mimeType)) { + qDebug() << "Identified as Backup"; return FileType::Backups; } else { + qDebug() << "Identified as Unknown type"; return FileType::Unknown; } } QString MimeTypeDisplayManager::defaultIcon(const QString &mimeType) { + qDebug() << "Getting default icon for MIME type:" << mimeType; return m_defaultIconNames.value(displayNameToEnum(mimeType)); } QMap MimeTypeDisplayManager::displayNames() { + qDebug() << "Getting all display names"; return m_displayNames; } @@ -116,6 +129,7 @@ QStringList MimeTypeDisplayManager::readlines(const QString &path) QString line = in.readLine(); // Skip empty line or line with invalid format if (line.trimmed().isEmpty()) { + qDebug() << "Skipping empty line"; continue; } @@ -123,15 +137,8 @@ QStringList MimeTypeDisplayManager::readlines(const QString &path) } file.close(); + qDebug() << "Read" << result.size() << "MIME types from file"; return result; - qDebug() << "Supported MIME types loaded:" - << "Archive:" << ArchiveMimeTypes.size() - << "Text:" << TextMimeTypes.size() - << "Video:" << VideoMimeTypes.size() - << "Audio:" << AudioMimeTypes.size() - << "Image:" << ImageMimeTypes.size() - << "Executable:" << ExecutableMimeTypes.size() - << "Backup:" << BackupMimeTypes.size(); } void MimeTypeDisplayManager::loadSupportMimeTypes() @@ -151,14 +158,25 @@ void MimeTypeDisplayManager::loadSupportMimeTypes() ImageMimeTypes = readlines(imagePath); ExecutableMimeTypes = readlines(executablePath); BackupMimeTypes = readlines(backupPath); + + qDebug() << "Supported MIME types loaded:" + << "Archive:" << ArchiveMimeTypes.size() + << "Text:" << TextMimeTypes.size() + << "Video:" << VideoMimeTypes.size() + << "Audio:" << AudioMimeTypes.size() + << "Image:" << ImageMimeTypes.size() + << "Executable:" << ExecutableMimeTypes.size() + << "Backup:" << BackupMimeTypes.size(); } QStringList MimeTypeDisplayManager::supportArchiveMimetypes() { + qDebug() << "Getting supported archive MIME types, count:" << ArchiveMimeTypes.size(); return ArchiveMimeTypes; } QStringList MimeTypeDisplayManager::supportVideoMimeTypes() { + qDebug() << "Getting supported video MIME types, count:" << VideoMimeTypes.size(); return VideoMimeTypes; } diff --git a/src/source/common/openFileWatcher.cpp b/src/source/common/openFileWatcher.cpp index 09e84443..bd6b945e 100644 --- a/src/source/common/openFileWatcher.cpp +++ b/src/source/common/openFileWatcher.cpp @@ -19,7 +19,7 @@ OpenFileWatcher::OpenFileWatcher(QObject *parent) OpenFileWatcher::~OpenFileWatcher() { - + qDebug() << "Destroying OpenFileWatcher"; } void OpenFileWatcher::reset() @@ -34,6 +34,7 @@ void OpenFileWatcher::reset() void OpenFileWatcher::setCurOpenFile(const QString &strCurOpenFile) { + // qDebug() << "Setting current open file:" << strCurOpenFile; m_strOpenFile = strCurOpenFile; } @@ -58,6 +59,7 @@ void OpenFileWatcher::addWatchFile(const QString &strFile) QMap &OpenFileWatcher::getFileHasModified() { + // qDebug() << "Getting file has modified map"; return m_mapFileHasModified; } @@ -69,5 +71,6 @@ void OpenFileWatcher::setCurFilePassword(const QString &strPassword) QMap OpenFileWatcher::getFilePassword() { + // qDebug() << "Getting file password map"; return m_mapFilePassword; } diff --git a/src/source/common/plugin.cpp b/src/source/common/plugin.cpp index 1136d84e..7aded641 100644 --- a/src/source/common/plugin.cpp +++ b/src/source/common/plugin.cpp @@ -19,29 +19,38 @@ Plugin::Plugin(QObject *parent, const KPluginMetaData &metaData) int Plugin::priority() const { + qDebug() << "Getting priority for plugin:" << m_metaData.pluginId(); const int priority = m_metaData.rawData()[QStringLiteral("X-KDE-Priority")].toInt(); + qDebug() << "Plugin priority:" << (priority > 0 ? priority : 0); return (priority > 0 ? priority : 0); } bool Plugin::isEnabled() const { + qDebug() << "Checking if plugin is enabled:" << m_metaData.pluginId() << "enabled:" << m_enabled; return m_enabled; } void Plugin::setEnabled(bool enabled) { + qDebug() << "Setting plugin enabled state:" << m_metaData.pluginId() << "to" << enabled; m_enabled = enabled; emit enabledChanged(); } bool Plugin::isReadWrite() const { + qDebug() << "Checking if plugin is read-write:" << m_metaData.pluginId(); const bool isDeclaredReadWrite = m_metaData.rawData()[QStringLiteral("X-KDE-Kerfuffle-ReadWrite")].toBool(); - return isDeclaredReadWrite && findExecutables(readWriteExecutables()); + bool hasExecutables = findExecutables(readWriteExecutables()); + bool result = isDeclaredReadWrite && hasExecutables; + qDebug() << "Plugin read-write check - declared:" << isDeclaredReadWrite << "has executables:" << hasExecutables << "result:" << result; + return result; } QStringList Plugin::readOnlyExecutables() const { + qDebug() << "Getting read-only executables for plugin:" << m_metaData.pluginId(); QStringList readOnlyExecutables; const QJsonArray array = m_metaData.rawData()[QStringLiteral("X-KDE-Kerfuffle-ReadOnlyExecutables")].toArray(); @@ -49,11 +58,13 @@ QStringList Plugin::readOnlyExecutables() const readOnlyExecutables << value.toString(); } + qDebug() << "Read-only executables:" << readOnlyExecutables; return readOnlyExecutables; } QStringList Plugin::readWriteExecutables() const { + qDebug() << "Getting read-write executables for plugin:" << m_metaData.pluginId(); QStringList readWriteExecutables; const QJsonArray array = m_metaData.rawData()[QStringLiteral("X-KDE-Kerfuffle-ReadWriteExecutables")].toArray(); @@ -61,17 +72,22 @@ QStringList Plugin::readWriteExecutables() const readWriteExecutables << value.toString(); } + qDebug() << "Read-write executables:" << readWriteExecutables; return readWriteExecutables; } KPluginMetaData Plugin::metaData() const { + qDebug() << "Getting metadata for plugin:" << m_metaData.pluginId(); return m_metaData; } bool Plugin::hasRequiredExecutables() const { - return findExecutables(readOnlyExecutables()); + qDebug() << "Checking required executables for plugin:" << m_metaData.pluginId(); + bool result = findExecutables(readOnlyExecutables()); + qDebug() << "Required executables check result:" << result; + return result; } bool Plugin::isValid() const @@ -86,6 +102,7 @@ bool Plugin::findExecutables(const QStringList &executables) qDebug() << "Searching for required executables:" << executables; for (const QString &executable : executables) { if (executable.isEmpty()) { + qDebug() << "Skipping empty executable"; continue; } diff --git a/src/source/common/pluginmanager.cpp b/src/source/common/pluginmanager.cpp index 587d76a0..4ea598c8 100644 --- a/src/source/common/pluginmanager.cpp +++ b/src/source/common/pluginmanager.cpp @@ -32,6 +32,7 @@ PluginManager::PluginManager(QObject *parent) PluginManager &PluginManager::get_instance() { + // qDebug() << "Getting PluginManager instance"; #ifndef Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE if (!QAtomicPointer::isTestAndSetNative()) //运行时检测 qInfo() << "Error: TestAndSetNative not supported!"; @@ -43,6 +44,7 @@ PluginManager &PluginManager::get_instance() * 不会被重新排序。 */ if (m_instance.testAndSetOrdered(nullptr, nullptr)) { //第一次检测 + qDebug() << "Creating new PluginManager instance"; QMutexLocker locker(&m_mutex);//加互斥锁。 m_instance.testAndSetOrdered(nullptr, new PluginManager);//第二次检测。 @@ -53,11 +55,13 @@ PluginManager &PluginManager::get_instance() QVector PluginManager::installedPlugins() const { + qDebug() << "Getting installed plugins, count:" << m_plugins.size(); return m_plugins; } QVector PluginManager::availablePlugins() const { + qDebug() << "Getting available plugins"; QVector availablePlugins; for (Plugin *plugin : qAsConst(m_plugins)) { if (plugin->isValid()) { @@ -65,11 +69,13 @@ QVector PluginManager::availablePlugins() const } } + qDebug() << "Found" << availablePlugins.size() << "available plugins"; return availablePlugins; } QVector PluginManager::availableWritePlugins() const { + qDebug() << "Getting available write plugins"; QVector availableWritePlugins; const auto plugins = availablePlugins(); for (Plugin *plugin : plugins) { @@ -78,11 +84,13 @@ QVector PluginManager::availableWritePlugins() const } } + qDebug() << "Found" << availableWritePlugins.size() << "available write plugins"; return availableWritePlugins; } QVector PluginManager::enabledPlugins() const { + qDebug() << "Getting enabled plugins"; QVector enabledPlugins; for (Plugin *plugin : qAsConst(m_plugins)) { if (plugin->isEnabled()) { @@ -90,43 +98,62 @@ QVector PluginManager::enabledPlugins() const } } + qDebug() << "Found" << enabledPlugins.size() << "enabled plugins"; return enabledPlugins; } QVector PluginManager::preferredPluginsFor(const CustomMimeType &mimeType) { + qDebug() << "Getting preferred plugins for mime type:" << mimeType.name(); const auto mimeName = mimeType.name(); if (m_preferredPluginsCache.contains(mimeName)) { + qDebug() << "Using cached preferred plugins for:" << mimeName; return m_preferredPluginsCache.value(mimeName); } const auto plugins = preferredPluginsFor(mimeType, false); m_preferredPluginsCache.insert(mimeName, plugins); + qDebug() << "Cached" << plugins.size() << "preferred plugins for:" << mimeName; return plugins; } QVector PluginManager::preferredWritePluginsFor(const CustomMimeType &mimeType) const { + qDebug() << "Getting preferred write plugins for mime type:" << mimeType.name(); return preferredPluginsFor(mimeType, true); } Plugin *PluginManager::preferredPluginFor(const CustomMimeType &mimeType) { + qDebug() << "Getting preferred plugin for mime type:" << mimeType.name(); const QVector preferredPlugins = preferredPluginsFor(mimeType); - return preferredPlugins.isEmpty() ? new Plugin() : preferredPlugins.first(); + if (preferredPlugins.isEmpty()) { + qWarning() << "No preferred plugin found for mime type:" << mimeType.name(); + return new Plugin(); + } + qDebug() << "Using preferred plugin:" << preferredPlugins.first()->metaData().pluginId(); + return preferredPlugins.first(); } Plugin *PluginManager::preferredWritePluginFor(const CustomMimeType &mimeType) const { + qDebug() << "Getting preferred write plugin for mime type:" << mimeType.name(); const QVector preferredWritePlugins = preferredWritePluginsFor(mimeType); - return preferredWritePlugins.isEmpty() ? new Plugin() : preferredWritePlugins.first(); + if (preferredWritePlugins.isEmpty()) { + qWarning() << "No preferred write plugin found for mime type:" << mimeType.name(); + return new Plugin(); + } + qDebug() << "Using preferred write plugin:" << preferredWritePlugins.first()->metaData().pluginId(); + return preferredWritePlugins.first(); } QStringList PluginManager::supportedMimeTypes(MimeSortingMode mode) const { + qDebug() << "Getting supported mime types with mode:" << mode; QSet supported; QMimeDatabase db; const auto plugins = availablePlugins(); + qDebug() << "Processing" << plugins.size() << "available plugins"; for (Plugin *plugin : plugins) { const auto mimeTypes = plugin->metaData().mimeTypes(); for (const auto &mimeType : mimeTypes) { @@ -138,31 +165,38 @@ QStringList PluginManager::supportedMimeTypes(MimeSortingMode mode) const // Remove entry for lrzipped tar if lrzip executable not found in path. if (QStandardPaths::findExecutable(QStringLiteral("lrzip")).isEmpty()) { + qDebug() << "Removing lrzip-compressed-tar support - executable not found"; supported.remove(QStringLiteral("application/x-lrzip-compressed-tar")); } // Remove entry for lz4-compressed tar if lz4 executable not found in path. if (QStandardPaths::findExecutable(QStringLiteral("lz4")).isEmpty()) { + qDebug() << "Removing lz4-compressed-tar support - executable not found"; supported.remove(QStringLiteral("application/x-lz4-compressed-tar")); } // Remove entry for lzo-compressed tar if libarchive not linked against lzo and lzop executable not found in path. if (!libarchiveHasLzo() && QStandardPaths::findExecutable(QStringLiteral("lzop")).isEmpty()) { + qDebug() << "Removing tzo support - no lzo support and lzop not found"; supported.remove(QStringLiteral("application/x-tzo")); } if (mode == SortByComment) { + qDebug() << "Sorting mime types by comment"; return sortByComment(supported); } + qDebug() << "Found" << supported.size() << "supported mime types"; return supported.values(); } QStringList PluginManager::supportedWriteMimeTypes(MimeSortingMode mode) const { + qDebug() << "Getting supported write mime types with mode:" << mode; QSet supported; QMimeDatabase db; const auto plugins = availableWritePlugins(); + qDebug() << "Processing" << plugins.size() << "available write plugins"; for (Plugin *plugin : plugins) { const auto mimeTypes = plugin->metaData().mimeTypes(); for (const auto &mimeType : mimeTypes) { @@ -174,29 +208,36 @@ QStringList PluginManager::supportedWriteMimeTypes(MimeSortingMode mode) const // Remove entry for lrzipped tar if lrzip executable not found in path. if (QStandardPaths::findExecutable(QStringLiteral("lrzip")).isEmpty()) { + qDebug() << "Removing lrzip-compressed-tar write support - executable not found"; supported.remove(QStringLiteral("application/x-lrzip-compressed-tar")); } // Remove entry for lz4-compressed tar if lz4 executable not found in path. if (QStandardPaths::findExecutable(QStringLiteral("lz4")).isEmpty()) { + qDebug() << "Removing lz4-compressed-tar write support - executable not found"; supported.remove(QStringLiteral("application/x-lz4-compressed-tar")); } // Remove entry for lzo-compressed tar if libarchive not linked against lzo and lzop executable not found in path. if (!libarchiveHasLzo() && QStandardPaths::findExecutable(QStringLiteral("lzop")).isEmpty()) { + qDebug() << "Removing tzo write support - no lzo support and lzop not found"; supported.remove(QStringLiteral("application/x-tzo")); } + qDebug() << "Removing ISO image write support"; supported.remove(QStringLiteral("application/x-iso9660-image")); + qDebug() << "Removing RAR write support"; supported.remove(QStringLiteral("application/vnd.rar")); supported.remove(QStringLiteral("application/x-rar")); // supported.remove(QStringLiteral("application/octet-stream")); if (mode == SortByComment) { + qDebug() << "Sorting write mime types by comment"; return sortByComment(supported); } + qDebug() << "Found" << supported.size() << "supported write mime types"; return supported.values(); } @@ -234,6 +275,7 @@ QVector PluginManager::filterBy(const QVector &plugins, cons void PluginManager::setFileSize(qint64 size) { + qDebug() << "Setting file size to:" << size; m_filesize = size; } @@ -264,8 +306,10 @@ void PluginManager::loadPlugins() QVector PluginManager::preferredPluginsFor(const CustomMimeType &mimeType, bool readWrite) const { + qDebug() << "Getting preferred plugins for mime type:" << mimeType.name() << "readWrite:" << readWrite; QVector preferredPlugins = filterBy((readWrite ? availableWritePlugins() : availablePlugins()), mimeType); + qDebug() << "Sorting" << preferredPlugins.size() << "plugins by priority"; std::sort(preferredPlugins.begin(), preferredPlugins.end(), [](Plugin * p1, Plugin * p2) { return p1->priority() > p2->priority(); }); @@ -296,11 +340,13 @@ QVector PluginManager::preferredPluginsFor(const CustomMimeType &mimeT // } // } + qDebug() << "Returning" << preferredPlugins.size() << "preferred plugins"; return preferredPlugins; } QStringList PluginManager::sortByComment(const QSet &mimeTypes) { + qDebug() << "Sorting" << mimeTypes.size() << "mime types by comment"; QMap map; // Initialize the QMap to sort by comment. @@ -315,6 +361,7 @@ QStringList PluginManager::sortByComment(const QSet &mimeTypes) sortedMimeTypes << value; } + qDebug() << "Sorted mime types, result count:" << sortedMimeTypes.size(); return sortedMimeTypes; } diff --git a/src/source/common/uitools.cpp b/src/source/common/uitools.cpp index 50b3cec3..36c7ae45 100644 --- a/src/source/common/uitools.cpp +++ b/src/source/common/uitools.cpp @@ -69,33 +69,41 @@ QStringList UiTools::m_associtionlist = QStringList() << "file_association.file_ UiTools::UiTools(QObject *parent) : QObject(parent) { + qDebug() << "UiTools instance created"; } UiTools::~UiTools() { + qDebug() << "UiTools instance destroyed"; } QString UiTools::getConfigPath() { + qDebug() << "Getting config path"; QDir dir(QDir(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first()) .filePath(qApp->organizationName())); - return dir.filePath(qApp->applicationName()); + QString path = dir.filePath(qApp->applicationName()); + qDebug() << "Config path:" << path; + return path; } QPixmap UiTools::renderSVG(const QString &filePath, const QSize &size) { + qDebug() << "Rendering SVG:" << filePath << "size:" << size; QImageReader reader; QPixmap pixmap; reader.setFileName(filePath); if (reader.canRead()) { + qDebug() << "SVG can be read, scaling"; const qreal ratio = qApp->devicePixelRatio(); reader.setScaledSize(size * ratio); pixmap = QPixmap::fromImage(reader.read()); pixmap.setDevicePixelRatio(ratio); } else { + qDebug() << "SVG cannot be read, loading as regular image"; pixmap.load(filePath); } @@ -104,7 +112,9 @@ QPixmap UiTools::renderSVG(const QString &filePath, const QSize &size) QString UiTools::humanReadableSize(const qint64 &size, int precision) { + qDebug() << "Converting size to human readable:" << size; if (0 == size) { + qDebug() << "Size is 0, returning dash"; return "-"; } @@ -120,7 +130,9 @@ QString UiTools::humanReadableSize(const qint64 &size, int precision) sizeAsDouble /= 1024.0; } - return QString::fromLatin1("%1 %2").arg(sizeAsDouble, 0, 'f', precision).arg(measure); + QString result = QString::fromLatin1("%1 %2").arg(sizeAsDouble, 0, 'f', precision).arg(measure); + qDebug() << "Human readable size:" << result; + return result; } bool UiTools::isArchiveFile(const QString &strFileName) @@ -162,6 +174,7 @@ bool UiTools::isArchiveFile(const QString &strFileName) bool UiTools::isExistMimeType(const QString &strMimeType, bool &bArchive) { + qDebug() << "Checking if MIME type exists:" << strMimeType; QString conf = readConf(); QStringList confList = conf.split("\n", SKIP_EMPTY_PARTS); @@ -170,31 +183,38 @@ bool UiTools::isExistMimeType(const QString &strMimeType, bool &bArchive) if (confList.at(i).contains("." + strMimeType + ":")) { bArchive = true; if (confList.at(i).contains("true")) { + qDebug() << "MIME type found and enabled:" << strMimeType; exist = true; break; } else { + qDebug() << "MIME type found but disabled:" << strMimeType; exist = false; continue; } } } + qDebug() << "MIME type check result:" << exist; return exist; } QString UiTools::readConf() { + qDebug() << "Reading configuration file"; const QString confDir = DStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); QDir dir; if (!dir.exists(confDir + QDir::separator())) { + qDebug() << "Config directory does not exist, creating:" << confDir; dir.mkpath(confDir + QDir::separator()); } const QString confPath = confDir + QDir::separator() + "deepin-compressor.confbf"; + qDebug() << "Config file path:" << confPath; QFile confFile(confPath); // default settings if (!confFile.exists()) { + qDebug() << "Config file does not exist, creating with defaults"; confFile.open(QIODevice::WriteOnly | QIODevice::Text); foreach (QString key, m_associtionlist) { @@ -208,19 +228,25 @@ QString UiTools::readConf() QString confValue; bool readStatus = confFile.open(QIODevice::ReadOnly | QIODevice::Text); if (readStatus) { + qDebug() << "Successfully opened config file for reading"; confValue = confFile.readAll(); + } else { + qWarning() << "Failed to open config file for reading"; } confFile.close(); + qDebug() << "Config file read, size:" << confValue.size(); return confValue; } QString UiTools::toShortString(QString strSrc, int limitCounts, int left) { + qDebug() << "Converting string to short format:" << strSrc << "limit:" << limitCounts; left = (left >= limitCounts || left <= 0) ? limitCounts / 2 : left; int right = limitCounts - left; QString displayName = ""; displayName = strSrc.length() > limitCounts ? strSrc.left(left) + "..." + strSrc.right(right) : strSrc; + qDebug() << "Short string result:" << displayName; return displayName; } @@ -254,44 +280,52 @@ ReadOnlyArchiveInterface *UiTools::createInterface(const QString &fileName, bool if (eType != APT_Cli7z) { if (((!bWrite) && (mimeType.name() == QString("application/zip") || mimeType.name() == QString("application/x-tar"))) || ("application/x-tzo" == mimeType.name() && "application/x-lzop" == mimeFromContent.name())) { + qDebug() << "Setting flag to remove 7zip plugin for zip/tar/tzo formats"; remove7zFlag = true; } } // 创建插件 ReadOnlyArchiveInterface *pIface = nullptr; + qDebug() << "Iterating through" << offers.size() << "plugins"; for (Plugin *plugin : offers) { //删除P7zip插件 if (remove7zFlag && plugin->metaData().name().contains("7zip", Qt::CaseInsensitive)) { + qDebug() << "Skipping 7zip plugin due to remove flag"; continue; } switch (eType) { // 自动识别 case APT_Auto: + qDebug() << "Using auto-detect plugin type"; pIface = createInterface(fileName, mimeType, plugin); break; // cli7zplugin case APT_Cli7z: if (plugin->metaData().name().contains("7zip", Qt::CaseInsensitive)) { + qDebug() << "Using 7zip plugin"; pIface = createInterface(fileName, mimeType, plugin); } break; // libarchive case APT_Libarchive: if (plugin->metaData().name().contains("libarchive", Qt::CaseInsensitive)) { + qDebug() << "Using libarchive plugin"; pIface = createInterface(fileName, mimeType, plugin); } break; // libzipplugin case APT_Libzip: if (plugin->metaData().name().contains("libzip", Qt::CaseInsensitive)) { + qDebug() << "Using libzip plugin"; pIface = createInterface(fileName, mimeType, plugin); } break; // libpigzplugin case APT_Libpigz: if (plugin->metaData().name().contains("pigz", Qt::CaseInsensitive)) { + qDebug() << "Using pigz plugin"; pIface = createInterface(fileName, mimeType, plugin); } break; @@ -300,19 +334,27 @@ ReadOnlyArchiveInterface *UiTools::createInterface(const QString &fileName, bool // Use the first valid plugin, according to the priority sorting. if (pIface) { qInfo() << "选用插件:" << plugin->metaData().pluginId(); + qDebug() << "Successfully created interface with plugin"; break; + } else { + qDebug() << "Failed to create interface with plugin:" << plugin->metaData().pluginId(); } } + if (!pIface) { + qWarning() << "No suitable plugin found for file:" << fileName; + } return pIface; } ReadOnlyArchiveInterface *UiTools::createInterface(const QString &fileName, const CustomMimeType &mimeType, Plugin *plugin) { + qDebug() << "Creating interface with plugin:" << plugin->metaData().pluginId() << "for file:" << fileName; Q_ASSERT(plugin); KPluginFactory *factory = KPluginLoader(plugin->metaData().fileName()).factory(); if (!factory) { + qWarning() << "Failed to load plugin factory for:" << plugin->metaData().fileName(); return nullptr; } @@ -322,42 +364,56 @@ ReadOnlyArchiveInterface *UiTools::createInterface(const QString &fileName, cons }; ReadOnlyArchiveInterface *iface = factory->create(nullptr, args); + if (iface) { + qDebug() << "Successfully created interface"; + } else { + qWarning() << "Failed to create interface"; + } return iface; } void UiTools::transSplitFileName(QString &fileName, UnCompressParameter::SplitType &eSplitType) { + qDebug() << "Processing split filename:" << fileName; if (fileName.contains(".7z.")) { + qDebug() << "Processing 7z split archive"; // 7z分卷处理 REG_EXP reg("^([\\s\\S]*\\.)7z\\.[0-9]{3}$"); // QRegExp reg("[*.]part\\d+.rar$"); //rar分卷不匹配 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (reg.exactMatch(fileName)) { + qDebug() << "7z split pattern matched, converting to .001"; fileName = reg.cap(1) + "7z.001"; //例如: *.7z.003 -> *.7z.001 #else QRegularExpressionMatch match = reg.match(fileName); if (match.hasMatch()) { + qDebug() << "7z split pattern matched, converting to .001"; fileName = match.captured(1) + "7z.001"; //例如: *.7z.003 -> *.7z.001 #endif eSplitType = UnCompressParameter::ST_Other; } } else if (fileName.contains(".part") && fileName.endsWith(".rar")) { // rar分卷处理 + qDebug() << "Processing RAR split archive"; int x = fileName.lastIndexOf("part"); int y = fileName.lastIndexOf("."); if ((y - x) > 5) { + qDebug() << "Converting RAR split to part01 format"; fileName.replace(x, y - x, "part01"); } else { + qDebug() << "Converting RAR split to part1 format"; fileName.replace(x, y - x, "part1"); } eSplitType = UnCompressParameter::ST_Other; } else if (fileName.contains(".zip.")) { // 1.zip.001格式 + qDebug() << "Processing ZIP split archive"; REG_EXP reg("^([\\s\\S]*\\.)zip\\.[0-9]{3}$"); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (reg.exactMatch(fileName)) { QFileInfo fi(reg.cap(1) + "zip.001"); if (fi.exists() == true) { + qDebug() << "ZIP split .001 file exists, converting"; fileName = reg.cap(1) + "zip.001"; eSplitType = UnCompressParameter::ST_Zip; } @@ -367,6 +423,7 @@ void UiTools::transSplitFileName(QString &fileName, UnCompressParameter::SplitTy if (match.hasMatch()) { QFileInfo fi(match.captured(1) + "zip.001"); if (fi.exists() == true) { + qDebug() << "ZIP split .001 file exists, converting"; fileName = match.captured(1) + "zip.001"; eSplitType = UnCompressParameter::ST_Zip; } @@ -377,8 +434,10 @@ void UiTools::transSplitFileName(QString &fileName, UnCompressParameter::SplitTy * 例如123.zip文件,检测123.z01文件是否存在 * 如果存在,则认定123.zip是分卷包 */ + qDebug() << "Checking for ZIP split format (.z01)"; QFileInfo tmp(fileName.left(fileName.length() - 2) + "01"); if (tmp.exists()) { + qDebug() << "Found corresponding .z01 file, marking as split"; eSplitType = UnCompressParameter::ST_Zip; } } else if (fileName.contains(".z")) { //1.zip 1.01格式 @@ -386,17 +445,21 @@ void UiTools::transSplitFileName(QString &fileName, UnCompressParameter::SplitTy * 例如123.z01文件,检测123.zip文件是否存在 * 如果存在,则认定123.z01是分卷包 */ + qDebug() << "Processing .z## split file"; REG_EXP reg("^([\\s\\S]*\\.)z[0-9]+$"); // #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (reg.exactMatch(fileName)) { + qDebug() << "Converting .z## to .zip format"; fileName = reg.cap(1) + "zip"; #else QRegularExpressionMatch match = reg.match(fileName); if (match.hasMatch()) { + qDebug() << "Converting .z## to .zip format"; fileName = match.captured(1) + "zip"; #endif QFileInfo fi(fileName); if (fi.exists()) { + qDebug() << "Corresponding .zip file exists, marking as split"; eSplitType = UnCompressParameter::ST_Zip; } } @@ -405,45 +468,59 @@ void UiTools::transSplitFileName(QString &fileName, UnCompressParameter::SplitTy // 对软链接文件,需要找到源文件进行处理,否则某些操作会改变软链接属性 QFileInfo info(fileName); if (info.isSymLink()) { + qDebug() << "File is symlink, resolving target:" << info.symLinkTarget(); fileName = info.symLinkTarget(); } + qDebug() << "Final processed filename:" << fileName; } QString UiTools::handleFileName(const QString &strFileName) { + qDebug() << "Handling filename:" << strFileName; QFileInfo info(strFileName); QString strName = info.completeBaseName(); // 文件夹和文件获取的方式不一样 if (info.filePath().contains(".tar.")) { + qDebug() << "Removing .tar from filename"; strName = strName.remove(".tar"); // 类似tar.gz压缩文件,创建文件夹的时候移除.tar } else if (info.filePath().contains(".7z.")) { + qDebug() << "Removing .7z from filename"; strName = strName.remove(".7z"); // 7z分卷文件,创建文件夹的时候移除.7z } else if (info.filePath().contains(".part01.rar")) { + qDebug() << "Removing .part01 from filename"; strName = strName.remove(".part01"); // rar分卷文件,创建文件夹的时候移除part01 } else if (info.filePath().contains(".part1.rar")) { + qDebug() << "Removing .part1 from filename"; strName = strName.remove(".part1"); // rar分卷文件,创建文件夹的时候移除.part1 } else if (info.filePath().contains(".zip.")) { + qDebug() << "Removing .zip from filename"; strName = strName.remove(".zip"); // zip分卷文件,创建文件夹的时候移除.zip } + qDebug() << "Final handled filename:" << strName; return strName; } bool UiTools::isLocalDeviceFile(const QString &strFileName) { + qDebug() << "Checking if file is on local device:" << strFileName; QStorageInfo info(strFileName); QString sDevice = info.device(); - return sDevice.startsWith("/dev/") || sDevice.startsWith("dlnfs"); //长文件名开启后以dlnfs方式挂载 + bool result = sDevice.startsWith("/dev/") || sDevice.startsWith("dlnfs"); //长文件名开启后以dlnfs方式挂载 + qDebug() << "Device:" << sDevice << "is local:" << result; + return result; } QStringList UiTools::removeSameFileName(const QStringList &listFiles) { + qDebug() << "Removing duplicate filenames from list of" << listFiles.count() << "files"; QStringList listResult; QStringList listName; for (int i = 0; i < listFiles.count(); ++i) { QFileInfo info(listFiles[i]); if (listName.contains(info.fileName())) { + qDebug() << "Skipping duplicate filename:" << info.fileName(); continue; } else { listResult << listFiles[i]; @@ -451,18 +528,23 @@ QStringList UiTools::removeSameFileName(const QStringList &listFiles) } } + qDebug() << "Removed" << (listFiles.count() - listResult.count()) << "duplicates, result count:" << listResult.count(); return listResult; } bool UiTools::isWayland() { + qDebug() << "Checking if running on Wayland"; auto e = QProcessEnvironment::systemEnvironment(); QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE")); QString WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY")); + qDebug() << "XDG_SESSION_TYPE:" << XDG_SESSION_TYPE << "WAYLAND_DISPLAY:" << WAYLAND_DISPLAY; if (XDG_SESSION_TYPE == QLatin1String("wayland") || WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive)) { + qDebug() << "Running on Wayland"; return true; } else { + qDebug() << "Not running on Wayland"; return false; } } diff --git a/src/source/compressorapplication.cpp b/src/source/compressorapplication.cpp index fa0f3303..dcbe7dd9 100644 --- a/src/source/compressorapplication.cpp +++ b/src/source/compressorapplication.cpp @@ -25,7 +25,7 @@ CompressorApplication::~CompressorApplication() bool CompressorApplication::notify(QObject *watched, QEvent *event) { - qDebug() << "Processing application event notification"; + // qDebug() << "Processing application event notification"; if (QEvent::KeyPress == event->type()) { QKeyEvent *keyEvent = dynamic_cast(event); @@ -52,7 +52,7 @@ bool CompressorApplication::notify(QObject *watched, QEvent *event) } } else if (Qt::Key_Tab == keyOfEvent || Qt::Key_Backtab == keyOfEvent || Qt::Key_Left == keyOfEvent || Qt::Key_Up == keyOfEvent) { - qDebug() << "Handling navigation key press"; + // qDebug() << "Handling navigation key press"; QWidget *pWgt = activeWindow(); MainWindow *pWindow = qobject_cast(pWgt); //在对应的MainWindow操作 if (pWindow) { @@ -66,7 +66,7 @@ bool CompressorApplication::notify(QObject *watched, QEvent *event) } } - qDebug() << "Default event notification handling"; + // qDebug() << "Default event notification handling"; return DApplication::notify(watched, event); } diff --git a/src/source/dialog/openwithdialog/desktopfile.cpp b/src/source/dialog/openwithdialog/desktopfile.cpp index 51e5e8ea..d4fc1e43 100644 --- a/src/source/dialog/openwithdialog/desktopfile.cpp +++ b/src/source/dialog/openwithdialog/desktopfile.cpp @@ -20,6 +20,7 @@ DesktopFile::DesktopFile(const QString &fileName) qDebug() << "DesktopFile constructor started, file:" << fileName; // File validity if (m_fileName.isEmpty() || !QFile::exists(fileName)) { + qWarning() << "Desktop file is empty or does not exist:" << fileName; return; } @@ -31,42 +32,55 @@ DesktopFile::DesktopFile(const QString &fileName) if (desktop.contains("X-Deepin-AppID")) { m_deepinId = desktop.value("X-Deepin-AppID", settings.value("X-Deepin-AppID")).toString(); qInfo() << "Loaded X-Deepin-AppID:" << m_deepinId; + } else { + qDebug() << "No X-Deepin-AppID found"; } if (desktop.contains("X-Deepin-Vendor")) { m_deepinVendor = desktop.value("X-Deepin-Vendor", settings.value("X-Deepin-Vendor")).toString(); qInfo() << "Loaded X-Deepin-Vendor:" << m_deepinVendor; + } else { + qDebug() << "No X-Deepin-Vendor found"; } if (desktop.contains("NoDisplay")) { m_noDisplay = desktop.value("NoDisplay", settings.value("NoDisplay").toBool()).toBool(); + qDebug() << "NoDisplay set to:" << m_noDisplay; } if (desktop.contains("Hidden")) { m_hidden = desktop.value("Hidden", settings.value("Hidden").toBool()).toBool(); + qDebug() << "Hidden set to:" << m_hidden; } //由于获取的系统语言简写与.desktop的语言简写存在不对应关系,经决定先采用获取的系统值匹配 //若没匹配到则采用系统值"_"左侧的字符串进行匹配,均为匹配到,才走原未匹配流程 auto getValueFromSys = [&desktop, &settings](const QString & type, const QString & sysName)->QString { const QString key = QString("%0[%1]").arg(type).arg(sysName); - return desktop.value(key, settings.value(key)).toString(); + QString result = desktop.value(key, settings.value(key)).toString(); + qDebug() << "Getting localized value for key:" << key << "result:" << result; + return result; }; auto getNameByType = [&desktop, &settings, &getValueFromSys](const QString & type)->QString{ + qDebug() << "Getting name by type:" << type; QString tempSysName = QLocale::system().name(); QString targetName = getValueFromSys(type, tempSysName); if (targetName.isEmpty()) { + qDebug() << "No direct match found, trying language prefix"; auto strSize = tempSysName.trimmed().split("_"); if (!strSize.isEmpty()) { tempSysName = strSize.first(); targetName = getValueFromSys(type, tempSysName); } - if (targetName.isEmpty()) + if (targetName.isEmpty()) { + qDebug() << "No localized name found, using default"; targetName = desktop.value(type, settings.value(type)).toString(); + } } + qDebug() << "Final name for type" << type << ":" << targetName; return targetName; }; m_localName = getNameByType("Name"); @@ -77,11 +91,15 @@ DesktopFile::DesktopFile(const QString &fileName) m_icon = desktop.value("Icon", settings.value("Icon")).toString(); m_type = desktop.value("Type", settings.value("Type", "Application")).toString(); m_categories = desktop.value("Categories", settings.value("Categories").toString()).toString().remove(" ").split(";"); + qDebug() << "Loaded basic properties - exec:" << m_exec << "icon:" << m_icon << "type:" << m_type; QString mime_type = desktop.value("MimeType", settings.value("MimeType").toString()).toString().remove(" "); + qDebug() << "Raw MIME type string:" << mime_type; - if (!mime_type.isEmpty()) + if (!mime_type.isEmpty()) { m_mimeType = mime_type.split(";"); + qDebug() << "Parsed MIME types:" << m_mimeType; + } // Fix categories if (m_categories.first().compare("") == 0) { m_categories.removeFirst(); @@ -108,69 +126,82 @@ QString DesktopFile::getPureFileName() const QString DesktopFile::getName() const { + qDebug() << "Getting desktop file name:" << m_name; return m_name; } QString DesktopFile::getLocalName() const { + qDebug() << "Getting desktop file local name:" << m_localName; return m_localName; } QString DesktopFile::getDisplayName() const { + QString displayName; if (m_deepinVendor == QStringLiteral("deepin") && !m_genericName.isEmpty()) { - return m_genericName; + qDebug() << "Using generic name for deepin vendor"; + displayName = m_genericName; + } else { + displayName = m_localName.isEmpty() ? m_name : m_localName; + qDebug() << "Using" << (m_localName.isEmpty() ? "name" : "local name") << "for display"; } - return m_localName.isEmpty() ? m_name : m_localName; + qDebug() << "Display name:" << displayName; + return displayName; } //--------------------------------------------------------------------------- QString DesktopFile::getExec() const { - qDebug() << "Getting desktop file exec command:" << m_exec; + // qDebug() << "Getting desktop file exec command:" << m_exec; return m_exec; } //--------------------------------------------------------------------------- QString DesktopFile::getIcon() const { - qDebug() << "Getting desktop file icon:" << m_icon; + // qDebug() << "Getting desktop file icon:" << m_icon; return m_icon; } //--------------------------------------------------------------------------- QString DesktopFile::getType() const { + // qDebug() << "Getting desktop file type:" << m_type; return m_type; } QString DesktopFile::getDeepinId() const { + // qDebug() << "Getting Deepin ID:" << m_deepinId; return m_deepinId; } QString DesktopFile::getDeepinVendor() const { + // qDebug() << "Getting Deepin vendor:" << m_deepinVendor; return m_deepinVendor; } bool DesktopFile::getNoShow() const { - return m_noDisplay || m_hidden; + bool noShow = m_noDisplay || m_hidden; + // qDebug() << "Getting NoShow status:" << noShow << "(NoDisplay:" << m_noDisplay << "Hidden:" << m_hidden << ")"; + return noShow; } //--------------------------------------------------------------------------- QStringList DesktopFile::getCategories() const { - qDebug() << "Getting desktop file categories:" << m_categories; + // qDebug() << "Getting desktop file categories:" << m_categories; return m_categories; } //--------------------------------------------------------------------------- QStringList DesktopFile::getMimeType() const { - qDebug() << "Getting desktop file MIME types:" << m_mimeType; + // qDebug() << "Getting desktop file MIME types:" << m_mimeType; return m_mimeType; } //--------------------------------------------------------------------------- diff --git a/src/source/dialog/openwithdialog/mimesappsmanager.cpp b/src/source/dialog/openwithdialog/mimesappsmanager.cpp index 5d208d97..491e0fa6 100644 --- a/src/source/dialog/openwithdialog/mimesappsmanager.cpp +++ b/src/source/dialog/openwithdialog/mimesappsmanager.cpp @@ -56,24 +56,28 @@ MimeAppsWorker::MimeAppsWorker(QObject *parent): QObject(parent) MimeAppsWorker::~MimeAppsWorker() { - + qDebug() << "Destroying MimeAppsWorker"; } void MimeAppsWorker::initConnect() { + qDebug() << "Initializing MimeAppsWorker connections"; connect(m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &MimeAppsWorker::handleDirectoryChanged); connect(m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, &MimeAppsWorker::handleFileChanged); connect(m_updateCacheTimer, &QTimer::timeout, this, &MimeAppsWorker::updateCache); + qDebug() << "MimeAppsWorker connections established"; } void MimeAppsWorker::startWatch() { + qDebug() << "Starting file system watcher"; m_fileSystemWatcher->addPaths(MimesAppsManager::getDesktopFiles()); m_fileSystemWatcher->addPaths(MimesAppsManager::getApplicationsFolders()); } void MimeAppsWorker::handleDirectoryChanged(const QString &filePath) { + qDebug() << "Directory changed:" << filePath; Q_UNUSED(filePath) //for 1.4 @@ -131,11 +135,13 @@ void MimeAppsWorker::handleDirectoryChanged(const QString &filePath) // MimesAppsManager::DesktopObjs.remove(filePath); // } // updateCache(); + qDebug() << "Starting cache update timer due to directory change"; m_updateCacheTimer->start(); } void MimeAppsWorker::handleFileChanged(const QString &filePath) { + qDebug() << "File changed:" << filePath; Q_UNUSED(filePath) // updateCache(); m_updateCacheTimer->start(); @@ -196,12 +202,16 @@ void MimeAppsWorker::updateCache() bool MimeAppsWorker::writeData(const QString &path, const QByteArray &content) { + qDebug() << "Writing data to path:" << path << "size:" << content.size(); bool bResult = false; qInfo() << path; QFile file(path); if (file.open(QFile::WriteOnly)) { file.write(content); bResult = true; + qDebug() << "Successfully wrote data to file"; + } else { + qWarning() << "Failed to open file for writing:" << file.errorString(); } file.close(); @@ -210,13 +220,16 @@ bool MimeAppsWorker::writeData(const QString &path, const QByteArray &content) QByteArray MimeAppsWorker::readData(const QString &path) { + qDebug() << "Reading data from path:" << path; QFile file(path); if (!file.open(QFile::ReadOnly)) { qInfo() << path << "isn't exists!"; + return QByteArray(); } QByteArray content = file.readAll(); file.close(); + qDebug() << "Read" << content.size() << "bytes from file"; return content; } @@ -247,21 +260,29 @@ QMimeType MimesAppsManager::getMimeType(const QString &fileName) QString MimesAppsManager::getMimeTypeByFileName(const QString &fileName) { + qDebug() << "Getting MIME type by filename:" << fileName; DMimeDatabase db; QMimeType mimeType = db.mimeTypeForFile(fileName); + qDebug() << "MIME type result:" << mimeType.name(); return mimeType.name(); } QString MimesAppsManager::getDefaultAppByFileName(const QString &fileName) { + qDebug() << "Getting default app by filename:" << fileName; DMimeDatabase db; QMimeType mimeType = db.mimeTypeForFile(fileName); - return getDefaultAppByMimeType(mimeType); + QString result = getDefaultAppByMimeType(mimeType); + qDebug() << "Default app result:" << result; + return result; } QString MimesAppsManager::getDefaultAppByMimeType(const QMimeType &mimeType) { - return getDefaultAppByMimeType(mimeType.name()); + qDebug() << "Getting default app by QMimeType:" << mimeType.name(); + QString result = getDefaultAppByMimeType(mimeType.name()); + qDebug() << "Default app result:" << result; + return result; } QString MimesAppsManager::getDefaultAppByMimeType(const QString &mimeType) @@ -281,11 +302,15 @@ QString MimesAppsManager::getDefaultAppByMimeType(const QString &mimeType) QString MimesAppsManager::getDefaultAppDisplayNameByMimeType(const QMimeType &mimeType) { - return getDefaultAppDisplayNameByGio(mimeType.name()); + qDebug() << "Getting default app display name by QMimeType:" << mimeType.name(); + QString result = getDefaultAppDisplayNameByGio(mimeType.name()); + qDebug() << "Display name result:" << result; + return result; } QString MimesAppsManager::getDefaultAppDisplayNameByGio(const QString &mimeType) { + qDebug() << "Getting default app display name by GIO for MIME type:" << mimeType; /* * * We have the appsForMimeList. Now we need to filter some applications out as per user's choice and get the default value @@ -300,6 +325,9 @@ QString MimesAppsManager::getDefaultAppDisplayNameByGio(const QString &mimeType) QString appDisplayName = ""; if (defaultApp) { appDisplayName = g_app_info_get_name(defaultApp); + qDebug() << "Found default app display name:" << appDisplayName; + } else { + qWarning() << "No default app found for MIME type:" << mimeType; } g_object_unref(defaultApp); @@ -308,15 +336,22 @@ QString MimesAppsManager::getDefaultAppDisplayNameByGio(const QString &mimeType) QString MimesAppsManager::getDefaultAppDesktopFileByMimeType(const QString &mimeType) { + qDebug() << "Getting default app desktop file by MIME type:" << mimeType; GAppInfo *defaultApp = g_app_info_get_default_for_type(mimeType.toLocal8Bit().constData(), FALSE); - if (!defaultApp) + if (!defaultApp) { + qWarning() << "No default app found for MIME type:" << mimeType; return ""; + } const char *desktop_id = g_app_info_get_id(defaultApp); GDesktopAppInfo *desktopAppInfo = g_desktop_app_info_new(desktop_id); - if (!desktopAppInfo) + if (!desktopAppInfo) { + qWarning() << "Failed to create desktop app info for:" << desktop_id; + g_object_unref(defaultApp); return ""; + } QString desktopFile = g_desktop_app_info_get_filename(desktopAppInfo); + qDebug() << "Default app desktop file:" << desktopFile; g_object_unref(defaultApp); g_object_unref(desktopAppInfo); @@ -448,17 +483,21 @@ QStringList MimesAppsManager::getRecommendedAppsByQio(const QMimeType &mimeType) QStringList MimesAppsManager::getRecommendedAppsByGio(const QString &mimeType) { + qDebug() << "Getting recommended apps by GIO for MIME type:" << mimeType; QStringList recommendApps; GList *recomendAppInfoList = g_app_info_get_recommended_for_type(mimeType.toLocal8Bit().constData()); GList *iterator = recomendAppInfoList; + qDebug() << "Found" << g_list_length(recomendAppInfoList) << "recommended apps"; while (iterator) { GAppInfo *appInfo = (GAppInfo *)iterator->data; if (appInfo) { const char *desktopId = g_app_info_get_id(appInfo); + qDebug() << "Processing recommended app:" << desktopId; GDesktopAppInfo *dekstopAppInfo = g_desktop_app_info_new(desktopId); QString app = g_desktop_app_info_get_filename(dekstopAppInfo); + qDebug() << "App filename:" << app; recommendApps << app; g_object_unref(dekstopAppInfo); @@ -468,11 +507,13 @@ QStringList MimesAppsManager::getRecommendedAppsByGio(const QString &mimeType) } g_list_free(recomendAppInfoList); + qDebug() << "Returning" << recommendApps.size() << "recommended apps"; return recommendApps; } QStringList MimesAppsManager::getApplicationsFolders() { + qDebug() << "Getting application folders"; QStringList desktopFolders; desktopFolders << QString("/usr/share/applications/") << QString("/usr/local/share/applications/") @@ -480,63 +521,83 @@ QStringList MimesAppsManager::getApplicationsFolders() << QString("/var/lib/flatpak/exports/share/applications") << QDir::homePath() + QString("/.local/share/flatpak/exports/share/applications") << QDir::homePath() + QString("/.local/share/applications"); + qDebug() << "Application folders:" << desktopFolders; return desktopFolders; } QString MimesAppsManager::getMimeAppsCacheFile() { - return QString("%1/%2").arg(DFMStandardPaths::location(DFMStandardPaths::CachePath), "MimeApps.json"); + QString path = QString("%1/%2").arg(DFMStandardPaths::location(DFMStandardPaths::CachePath), "MimeApps.json"); + qDebug() << "MIME apps cache file path:" << path; + return path; } QString MimesAppsManager::getMimeInfoCacheFilePath() { + qDebug() << "MIME info cache file path: /usr/share/applications/mimeinfo.cache"; return "/usr/share/applications/mimeinfo.cache"; } QString MimesAppsManager::getMimeInfoCacheFileRootPath() { + qDebug() << "MIME info cache file root path: /usr/share/applications"; return "/usr/share/applications"; } QString MimesAppsManager::getDesktopFilesCacheFile() { - return QString("%1/%2").arg(DFMStandardPaths::location(DFMStandardPaths::CachePath), "DesktopFiles.json"); + QString path = QString("%1/%2").arg(DFMStandardPaths::location(DFMStandardPaths::CachePath), "DesktopFiles.json"); + qDebug() << "Desktop files cache file path:" << path; + return path; } QString MimesAppsManager::getDesktopIconsCacheFile() { - return QString("%1/%2").arg(DFMStandardPaths::location(DFMStandardPaths::CachePath), "DesktopIcons.json"); + QString path = QString("%1/%2").arg(DFMStandardPaths::location(DFMStandardPaths::CachePath), "DesktopIcons.json"); + qDebug() << "Desktop icons cache file path:" << path; + return path; } QStringList MimesAppsManager::getDesktopFiles() { + qDebug() << "Getting desktop files from application folders"; QStringList desktopFiles; foreach (QString desktopFolder, getApplicationsFolders()) { + qDebug() << "Scanning folder:" << desktopFolder; QDirIterator it(desktopFolder, QStringList("*.desktop"), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + int fileCount = 0; while (it.hasNext()) { it.next(); desktopFiles.append(it.filePath()); + fileCount++; } + qDebug() << "Found" << fileCount << "desktop files in" << desktopFolder; } + qDebug() << "Total desktop files found:" << desktopFiles.size(); return desktopFiles; } QString MimesAppsManager::getDDEMimeTypeFile() { - return QString("%1/%2/%3").arg(getMimeInfoCacheFileRootPath(), "deepin", "dde-mimetype.list"); + QString path = QString("%1/%2/%3").arg(getMimeInfoCacheFileRootPath(), "deepin", "dde-mimetype.list"); + qDebug() << "DDE MIME type file path:" << path; + return path; } QMap MimesAppsManager::getDesktopObjs() { + qDebug() << "Creating desktop objects map"; QMap desktopObjs; - foreach (QString f, getApplicationsFolders()) { + QStringList appFolders = getApplicationsFolders(); + foreach (QString f, appFolders) { + // qDebug() << "Creating desktop object for:" << f; desktopObjs.insert(f, DesktopFile(f)); } - + qDebug() << "Created" << desktopObjs.size() << "desktop objects"; return desktopObjs; } @@ -580,10 +641,12 @@ void MimesAppsManager::initMimeTypeApps() } } + qDebug() << "Processing MIME type apps from cache"; foreach (QString key, mimeAppsSet.keys()) { QSet apps = mimeAppsSet.value(key); QStringList orderApps; if (apps.count() > 1) { + // qDebug() << "Sorting" << apps.count() << "apps for MIME type:" << key; QFileInfoList fileInfos; foreach (QString app, apps) { QFileInfo info(app); @@ -603,6 +666,7 @@ void MimesAppsManager::initMimeTypeApps() } //check mime apps from cache + qDebug() << "Reading MIME info cache file:" << getMimeInfoCacheFilePath(); QFile f(getMimeInfoCacheFilePath()); if (!f.open(QIODevice::ReadOnly)) { qInfo() << "failed to read mime info cache file:" << f.errorString(); @@ -613,8 +677,10 @@ void MimesAppsManager::initMimeTypeApps() QStringList imageDeksopList; QStringList textDekstopList; QStringList videoDesktopList; - + + int lineCount = 0; while (!f.atEnd()) { + lineCount++; QString data = f.readLine(); QString _desktops = data.split("=").last(); QString mimeType = data.split("=").first(); @@ -639,42 +705,62 @@ void MimesAppsManager::initMimeTypeApps() } } } + qDebug() << "Processed" << lineCount << "lines from MIME info cache"; + qDebug() << "Found audio apps:" << audioDesktopList.size() << "image apps:" << imageDeksopList.size() + << "text apps:" << textDekstopList.size() << "video apps:" << videoDesktopList.size(); f.close(); const QString mimeInfoCacheRootPath = getMimeInfoCacheFileRootPath(); + qDebug() << "Loading audio MIME apps"; foreach (QString desktop, audioDesktopList) { const QString path = QString("%1/%2").arg(mimeInfoCacheRootPath, desktop); - if (!QFile::exists(path)) + if (!QFile::exists(path)) { + qDebug() << "Audio desktop file not found:" << path; continue; + } DesktopFile df(path); AudioMimeApps.insert(path, df); } + qDebug() << "Loaded" << AudioMimeApps.size() << "audio MIME apps"; + qDebug() << "Loading image MIME apps"; foreach (QString desktop, imageDeksopList) { const QString path = QString("%1/%2").arg(mimeInfoCacheRootPath, desktop); - if (!QFile::exists(path)) + if (!QFile::exists(path)) { + qDebug() << "Image desktop file not found:" << path; continue; + } DesktopFile df(path); ImageMimeApps.insert(path, df); } + qDebug() << "Loaded" << ImageMimeApps.size() << "image MIME apps"; + qDebug() << "Loading text MIME apps"; foreach (QString desktop, textDekstopList) { const QString path = QString("%1/%2").arg(mimeInfoCacheRootPath, desktop); - if (!QFile::exists(path)) + if (!QFile::exists(path)) { + qDebug() << "Text desktop file not found:" << path; continue; + } DesktopFile df(path); TextMimeApps.insert(path, df); } + qDebug() << "Loaded" << TextMimeApps.size() << "text MIME apps"; + qDebug() << "Loading video MIME apps"; foreach (QString desktop, videoDesktopList) { const QString path = QString("%1/%2").arg(mimeInfoCacheRootPath, desktop); - if (!QFile::exists(path)) + if (!QFile::exists(path)) { + qDebug() << "Video desktop file not found:" << path; continue; + } DesktopFile df(path); VideoMimeApps.insert(path, df); } + qDebug() << "Loaded" << VideoMimeApps.size() << "video MIME apps"; + qDebug() << "MIME type apps initialization completed"; return; } @@ -740,21 +826,26 @@ bool MimesAppsManager::lessByDateTime(const QFileInfo &f1, const QFileInfo &f2) bool MimesAppsManager::removeOneDupFromList(QStringList &list, const QString desktopFilePath) { + qDebug() << "Removing duplicate from list for desktop file:" << desktopFilePath; if (list.removeOne(desktopFilePath)) { + qDebug() << "Removed exact match from list"; return true; } const DesktopFile target(desktopFilePath); + qDebug() << "Searching for duplicate by exec and name matching"; QMutableStringListIterator iter(list); while (iter.hasNext()) { const DesktopFile source(iter.next()); if (source.getExec() == target.getExec() && source.getLocalName() == target.getLocalName()) { + qDebug() << "Found and removed duplicate based on exec and name"; iter.remove(); return true; } } + qDebug() << "No duplicate found to remove"; return false; } diff --git a/src/source/dialog/openwithdialog/openwithdialog.cpp b/src/source/dialog/openwithdialog/openwithdialog.cpp index 2402dd48..dcdcb761 100644 --- a/src/source/dialog/openwithdialog/openwithdialog.cpp +++ b/src/source/dialog/openwithdialog/openwithdialog.cpp @@ -21,8 +21,11 @@ OpenWithDialogListItem::OpenWithDialogListItem(const QIcon &icon, const QString : QWidget(parent) , m_icon(icon) { - if (m_icon.isNull()) + qDebug() << "Creating OpenWithDialogListItem with text:" << text; + if (m_icon.isNull()) { + qDebug() << "Icon is null, using default application icon"; m_icon = QIcon::fromTheme("application-x-desktop"); + } m_pCheckBtn = new DIconButton(this); m_pCheckBtn->setFixedSize(10, 10); @@ -42,15 +45,17 @@ OpenWithDialogListItem::OpenWithDialogListItem(const QIcon &icon, const QString layout->addWidget(m_pTextLbl); setMouseTracking(true); + qDebug() << "OpenWithDialogListItem created successfully"; } OpenWithDialogListItem::~OpenWithDialogListItem() { - + qDebug() << "Destroying OpenWithDialogListItem"; } void OpenWithDialogListItem::setChecked(bool checked) { + qDebug() << "Setting OpenWithDialogListItem checked state to:" << checked; if (checked) { m_pCheckBtn->setIcon(DStyle::SP_MarkElement); } else { @@ -60,11 +65,14 @@ void OpenWithDialogListItem::setChecked(bool checked) QString OpenWithDialogListItem::text() const { - return m_pTextLbl->text(); + QString text = m_pTextLbl->text(); + qDebug() << "Getting OpenWithDialogListItem text:" << text; + return text; } void OpenWithDialogListItem::resizeEvent(QResizeEvent *e) { + qDebug() << "OpenWithDialogListItem resize event, new size:" << e->size(); QWidget::resizeEvent(e); m_pIconLbl->setFixedSize(e->size().height() - 20, e->size().height() - 20); @@ -73,6 +81,7 @@ void OpenWithDialogListItem::resizeEvent(QResizeEvent *e) void OpenWithDialogListItem::enterEvent(EnterEvent *e) { + qDebug() << "Mouse entered OpenWithDialogListItem"; Q_UNUSED(e) update(); @@ -82,6 +91,7 @@ void OpenWithDialogListItem::enterEvent(EnterEvent *e) void OpenWithDialogListItem::leaveEvent(QEvent *e) { + qDebug() << "Mouse left OpenWithDialogListItem"; Q_UNUSED(e) update(); @@ -93,9 +103,11 @@ void OpenWithDialogListItem::paintEvent(QPaintEvent *e) { Q_UNUSED(e) - if (!underMouse()) + if (!underMouse()) { return; + } + qDebug() << "Painting hover effect for OpenWithDialogListItem"; QPainter pa(this); QPainterPath path; @@ -113,6 +125,7 @@ OpenWithDialogListSparerItem::OpenWithDialogListSparerItem(const QString &title, , m_separator(new DHorizontalLine(this)) , m_title(new QLabel(title, this)) { + qDebug() << "Creating OpenWithDialogListSparerItem with title:" << title; QFont font; font.setPixelSize(18); m_title->setFont(font); @@ -123,11 +136,12 @@ OpenWithDialogListSparerItem::OpenWithDialogListSparerItem(const QString &title, layout->addWidget(m_title); layout->setContentsMargins(20, 0, 20, 0); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + qDebug() << "OpenWithDialogListSparerItem created successfully"; } OpenWithDialogListSparerItem::~OpenWithDialogListSparerItem() { - + qDebug() << "Destroying OpenWithDialogListSparerItem"; } @@ -157,15 +171,18 @@ OpenWithDialog::~OpenWithDialog() QList OpenWithDialog::getOpenStyle(const QString &strFileName) { + qDebug() << "Getting open style for file:" << strFileName; mimeAppsManager->initMimeTypeApps(); DMimeDatabase db; QMimeType mimeType = db.mimeTypeForFile(strFileName); const QStringList &recommendApps = mimeAppsManager->getRecommendedAppsByQio(mimeType); + qDebug() << "Found" << recommendApps.count() << "recommended apps for MIME type:" << mimeType.name(); QList listType;; for (int i = 0; i < recommendApps.count(); ++i) { const DesktopFile &desktop_info = mimeAppsManager->DesktopObjs.value(recommendApps.at(i)); + qDebug() << "Adding desktop file:" << desktop_info.getDisplayName(); // if (desktop_info.getFileName().contains("deepin-compressor")) { // continue; @@ -174,11 +191,13 @@ QList OpenWithDialog::getOpenStyle(const QString &strFileName) listType << desktop_info; } + qDebug() << "Returning" << listType.size() << "desktop files"; return listType; } void OpenWithDialog::resizeEvent(QResizeEvent *event) { + qDebug() << "OpenWithDialog resize event, new size:" << event->size(); m_titlebar->setFixedWidth(event->size().width()); DAbstractDialog::resizeEvent(event); @@ -190,15 +209,19 @@ bool OpenWithDialog::eventFilter(QObject *obj, QEvent *event) if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast(event); if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt) { + qDebug() << "Filtered synthesized mouse move event"; return true; } } if (event->type() == QEvent::MouseButtonPress) { + qDebug() << "Mouse button press event detected"; if (static_cast(event)->button() == Qt::LeftButton) { - if (OpenWithDialogListItem *item = qobject_cast(obj)) + if (OpenWithDialogListItem *item = qobject_cast(obj)) { + qDebug() << "Left button clicked on OpenWithDialogListItem"; checkItem(item); + } return true; } @@ -246,21 +269,26 @@ QString OpenWithDialog::showOpenWithDialog(OpenWithDialog::ShowType eType) QString OpenWithDialog::getProgramPathByExec(const QString &strExec) { + qDebug() << "Getting program path by exec:" << strExec; QString strProgramPath; if (strExec.isEmpty()) { // 应用路径为空时,使用默认应用程序 + qDebug() << "Exec is empty, using xdg-open as default"; strProgramPath = QStandardPaths::findExecutable("xdg-open"); //查询本地位置 } else { // 以/开头时,做字符串分割处理 QStringList list = strExec.split(" "); if (strExec.startsWith(QDir::separator())) { + qDebug() << "Exec starts with separator, using direct path"; strProgramPath = list[0]; } else { + qDebug() << "Finding executable for:" << list[0]; strProgramPath = QStandardPaths::findExecutable(list[0]); //查询本地位置 } } + qDebug() << "Program path resolved to:" << strProgramPath; return strProgramPath; } @@ -331,9 +359,11 @@ void OpenWithDialog::init() void OpenWithDialog::initConnections() { + qDebug() << "Initializing OpenWithDialog connections"; connect(m_pCancelButton, &QPushButton::clicked, this, &OpenWithDialog::close); connect(m_pChooseButton, &QPushButton::clicked, this, &OpenWithDialog::slotOpenFileByApp); connect(m_pOpenFileChooseButton, &QCommandLinkButton::clicked, this, &OpenWithDialog::slotUseOtherApplication); + qDebug() << "OpenWithDialog connections established"; } void OpenWithDialog::initData() @@ -430,6 +460,7 @@ void OpenWithDialog::checkItem(OpenWithDialogListItem *item) OpenWithDialogListItem *OpenWithDialog::createItem(const QIcon &icon, const QString &name, const QString &filePath, const QString &strExec) { + qDebug() << "Creating OpenWithDialogListItem with name:" << name << "file path:" << filePath; OpenWithDialogListItem *item = new OpenWithDialogListItem(icon, name, this); item->setProperty("app", filePath); @@ -437,6 +468,7 @@ OpenWithDialogListItem *OpenWithDialog::createItem(const QIcon &icon, const QStr item->setFixedSize(220, 50); item->installEventFilter(this); + qDebug() << "OpenWithDialogListItem created successfully"; return item; } @@ -452,23 +484,34 @@ void OpenWithDialog::slotUseOtherApplication() QFileInfo info(file_path); QString target_desktop_file_name("%1/%2-custom-open-%3.desktop"); + qDebug() << "Processing selected file:" << info.fileName(); target_desktop_file_name = target_desktop_file_name.arg(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)).arg(qApp->applicationName()).arg(m_mimeType.name().replace("/", "-")); + qDebug() << "Target desktop file name:" << target_desktop_file_name; if (file_path.endsWith(".desktop")) { + qDebug() << "Processing .desktop file"; for (const OpenWithDialog *w : m_pRecommandLayout->parentWidget()->findChildren()) { - if (w->property("app").toString() == file_path) + if (w->property("app").toString() == file_path) { + qDebug() << "Desktop file already exists in recommended apps"; return; + } } Properties desktop(file_path, "Desktop Entry"); - if (desktop.value("MimeType").toString().isEmpty()) + if (desktop.value("MimeType").toString().isEmpty()) { + qWarning() << "Desktop file has no MIME type, skipping"; return; + } - if (!QFile::link(file_path, target_desktop_file_name)) + if (!QFile::link(file_path, target_desktop_file_name)) { + qWarning() << "Failed to create link to desktop file"; return; + } + qDebug() << "Successfully linked desktop file"; } else if (info.isExecutable()) { + qDebug() << "Processing executable file"; Properties desktop; desktop.set("Type", "Application"); @@ -477,15 +520,22 @@ void OpenWithDialog::slotUseOtherApplication() desktop.set("Exec", file_path); desktop.set("MimeType", "*/*"); desktop.set("X-DDE-File-Manager-Custom-Open", m_mimeType.name()); + qDebug() << "Created desktop properties for executable"; - if (QFile::exists(target_desktop_file_name)) + if (QFile::exists(target_desktop_file_name)) { + qDebug() << "Removing existing target desktop file"; QFile(target_desktop_file_name).remove(); + } - if (!desktop.save(target_desktop_file_name, "Desktop Entry")) + if (!desktop.save(target_desktop_file_name, "Desktop Entry")) { + qWarning() << "Failed to save desktop file"; return; + } + qDebug() << "Successfully saved desktop file for executable"; } // remove old custom item + qDebug() << "Removing old custom items from layout"; for (int i = 0; i < m_pOtherLayout->count(); ++i) { QWidget *w = m_pOtherLayout->itemAt(i)->widget(); @@ -493,11 +543,13 @@ void OpenWithDialog::slotUseOtherApplication() continue; if (w->property("app").toString() == target_desktop_file_name) { + qDebug() << "Removing existing custom item"; m_pOtherLayout->removeWidget(w); w->deleteLater(); } } + qDebug() << "Creating new custom item for:" << info.fileName(); OpenWithDialogListItem *item = createItem(QIcon::fromTheme("application-x-desktop"), info.fileName(), target_desktop_file_name, ""); int other_layout_sizeHint_height = m_pOtherLayout->sizeHint().height(); @@ -505,6 +557,7 @@ void OpenWithDialog::slotUseOtherApplication() item->show(); m_pOtherLayout->parentWidget()->setFixedHeight(m_pOtherLayout->parentWidget()->height() + m_pOtherLayout->sizeHint().height() - other_layout_sizeHint_height); checkItem(item); + qDebug() << "Custom application added successfully"; } void OpenWithDialog::slotOpenFileByApp() diff --git a/src/source/dialog/popupdialog.cpp b/src/source/dialog/popupdialog.cpp index 44942682..7eaa2faa 100644 --- a/src/source/dialog/popupdialog.cpp +++ b/src/source/dialog/popupdialog.cpp @@ -66,24 +66,30 @@ int TipDialog::showDialog(const QString &strDesText, const QString btnMsg, Butto void TipDialog::autoFeed(DLabel *label) { + qDebug() << "Auto-feeding text for TipDialog"; NewStr newstr = autoCutText(m_strDesText, label); label->setText(newstr.resultStr); int height_lable = newstr.strList.size() * newstr.fontHeifht; label->setMinimumHeight(height_lable); if (0 == m_iLabelOldHeight) { // 第一次exec自动调整 + qDebug() << "First time adjusting size"; adjustSize(); } else { + qDebug() << "Adjusting height based on font change"; setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整 } m_iLabelOldHeight = height_lable; m_iDialogOldHeight = height(); + qDebug() << "TipDialog auto-feed completed, new height:" << height(); } void TipDialog::changeEvent(QEvent *event) { if (QEvent::FontChange == event->type()) { + qDebug() << "TipDialog font change event detected"; Dtk::Widget::DLabel *p = findChild("ContentLabel"); if (nullptr != p) { + qDebug() << "Updating TipDialog layout for font change"; autoFeed(p); } } @@ -136,24 +142,30 @@ int SimpleQueryDialog::showDialog(const QString &strDesText, const QString btnMs void SimpleQueryDialog::autoFeed(DLabel *label) { + qDebug() << "Auto-feeding text for SimpleQueryDialog"; NewStr newstr = autoCutText(m_strDesText, label); label->setText(newstr.resultStr); int height_lable = newstr.strList.size() * newstr.fontHeifht; label->setMinimumHeight(height_lable); if (0 == m_iLabelOldHeight) { // 第一次exec自动调整 + qDebug() << "First time adjusting size"; adjustSize(); } else { + qDebug() << "Adjusting height based on font change"; setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight + height_lable); //字号变化后自适应调整 } m_iLabelOldHeight = height_lable; m_iDialogOldHeight = height(); + qDebug() << "SimpleQueryDialog auto-feed completed, new height:" << height(); } void SimpleQueryDialog::changeEvent(QEvent *event) { if (QEvent::FontChange == event->type()) { + qDebug() << "SimpleQueryDialog font change event detected"; Dtk::Widget::DLabel *p = findChild("ContentLabel"); if (nullptr != p) { + qDebug() << "Updating SimpleQueryDialog layout for font change"; autoFeed(p); } } @@ -240,16 +252,19 @@ void OverwriteQueryDialog::showDialog(QString file, bool bDir) Overwrite_Result OverwriteQueryDialog::getDialogResult() { + qDebug() << "Getting overwrite dialog result:" << m_retType; return m_retType; } bool OverwriteQueryDialog::getApplyAll() { + qDebug() << "Getting apply all setting:" << m_applyAll; return m_applyAll; } void OverwriteQueryDialog::autoFeed(DLabel *label1, DLabel *label2) { + qDebug() << "Auto-feeding text for OverwriteQueryDialog"; NewStr newstr = autoCutText(m_strDesText, label2); label2->setText(newstr.resultStr); int height_lable = newstr.strList.size() * newstr.fontHeifht; @@ -259,25 +274,31 @@ void OverwriteQueryDialog::autoFeed(DLabel *label1, DLabel *label2) QFont font; QFontMetrics elideFont(font); label1->setText(elideFont.elidedText(m_strFilesname, Qt::ElideMiddle, 340)); + qDebug() << "Elided filename:" << label1->text(); if (0 == m_iLabelOldHeight) { // 第一次exec自动调整 + qDebug() << "First time adjusting size"; adjustSize(); } else { + qDebug() << "Adjusting height based on font change"; setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height - m_iCheckboxOld1Height + height_lable + 2 * newstr.fontHeifht); //字号变化后自适应调整 } m_iLabelOldHeight = height_lable; m_iLabelOld1Height = newstr.fontHeifht; m_iCheckboxOld1Height = newstr.fontHeifht; m_iDialogOldHeight = height(); + qDebug() << "OverwriteQueryDialog auto-feed completed, new height:" << height(); } void OverwriteQueryDialog::changeEvent(QEvent *event) { if (QEvent::FontChange == event->type()) { + qDebug() << "OverwriteQueryDialog font change event detected"; Dtk::Widget::DLabel *p = findChild("ContentLabel"); if (nullptr != p) { Dtk::Widget::DLabel *pNameLabel = findChild("NameLabel"); if (nullptr != pNameLabel) { + qDebug() << "Updating OverwriteQueryDialog layout for font change"; autoFeed(pNameLabel, p); } } @@ -290,15 +311,17 @@ void OverwriteQueryDialog::changeEvent(QEvent *event) ConvertDialog::ConvertDialog(QWidget *parent) : DDialog(parent) { + qDebug() << "ConvertDialog constructor"; setFixedWidth(380); // 提示框宽度固定 QPixmap pixmap = UiTools::renderSVG(":assets/icons/deepin/builtin/icons/compress_warning_32px.svg", QSize(64, 64)); setIcon(pixmap); + qDebug() << "ConvertDialog initialized with icon"; } ConvertDialog::~ConvertDialog() { - + qDebug() << "ConvertDialog destroyed"; } QStringList ConvertDialog::showDialog() @@ -387,25 +410,31 @@ QStringList ConvertDialog::showDialog() void ConvertDialog::autoFeed(DLabel *label) { + qDebug() << "Auto-feeding text for ConvertDialog"; NewStr newstr = autoCutText(m_strDesText, label); label->setText(newstr.resultStr); int height_lable = newstr.strList.size() * newstr.fontHeifht; label->setMinimumHeight(height_lable); if (0 == m_iLabelOldHeight) { // 第一次exec自动调整 + qDebug() << "First time adjusting size"; adjustSize(); } else { + qDebug() << "Adjusting height based on font change"; setMinimumHeight(m_iDialogOldHeight - m_iLabelOldHeight - m_iLabelOld1Height + height_lable + newstr.fontHeifht); //字号变化后自适应调整 } m_iLabelOldHeight = height_lable; m_iLabelOld1Height = newstr.fontHeifht; m_iDialogOldHeight = height(); + qDebug() << "ConvertDialog auto-feed completed, new height:" << height(); } void ConvertDialog::changeEvent(QEvent *event) { if (QEvent::FontChange == event->type()) { + qDebug() << "ConvertDialog font change event detected"; Dtk::Widget::DLabel *p = findChild("ContentLabel"); if (nullptr != p) { + qDebug() << "Updating ConvertDialog layout for font change"; autoFeed(p); } } @@ -417,15 +446,17 @@ void ConvertDialog::changeEvent(QEvent *event) AppendDialog::AppendDialog(QWidget *parent) : DDialog(parent) { + qDebug() << "AppendDialog constructor"; setFixedWidth(380); // 提示框宽度固定 QPixmap pixmap = UiTools::renderSVG(":assets/icons/deepin/builtin/icons/compress_warning_32px.svg", QSize(64, 64)); setIcon(pixmap); + qDebug() << "AppendDialog initialized with icon"; } AppendDialog::~AppendDialog() { - + qDebug() << "AppendDialog destroyed"; } int AppendDialog::showDialog(bool bMultiplePassword) @@ -503,30 +534,37 @@ int AppendDialog::showDialog(bool bMultiplePassword) QString AppendDialog::password() { + qDebug() << "Getting AppendDialog password (length:" << m_strPassword.length() << ")"; return m_strPassword; } void AppendDialog::autoFeed(DLabel *pLabel) { + qDebug() << "Auto-feeding text for AppendDialog"; NewStr newstr = autoCutText(m_strDesText, pLabel); pLabel->setText(newstr.resultStr); int height_lable = newstr.strList.size() * newstr.fontHeifht; pLabel->setMinimumHeight(height_lable); if (0 == m_iLabelOldHeight) { // 第一次exec自动调整 + qDebug() << "First time adjusting size"; adjustSize(); } else { + qDebug() << "Adjusting width based on font change"; setMinimumWidth(m_iDialogOldHeight - m_iLabelOldHeight - m_iCheckboxOld1Height + height_lable + newstr.fontHeifht); //字号变化后自适应调整 } m_iLabelOldHeight = height_lable; m_iCheckboxOld1Height = newstr.fontHeifht; m_iDialogOldHeight = height(); + qDebug() << "AppendDialog auto-feed completed, new height:" << height(); } void AppendDialog::changeEvent(QEvent *event) { if (QEvent::FontChange == event->type()) { + qDebug() << "AppendDialog font change event detected"; Dtk::Widget::DLabel *p = findChild("ContentLabel"); if (nullptr != p) { + qDebug() << "Updating AppendDialog layout for font change"; autoFeed(p); } } @@ -536,20 +574,24 @@ void AppendDialog::changeEvent(QEvent *event) RenameDialog::RenameDialog(QWidget *parent) : DDialog(parent) { + qDebug() << "RenameDialog constructor"; m_nOkBtnIndex = -1; m_lineEdit = NULL; setFixedSize(g_nDlgWidth, g_nDlgHeight); // 提示框宽度固定 m_isDirectory = false; QPixmap pixmap = UiTools::renderSVG(":assets/icons/deepin/builtin/icons/compress_warning_32px.svg", QSize(64, 64)); setIcon(pixmap); + qDebug() << "RenameDialog initialized with icon"; } RenameDialog::~RenameDialog() { + qDebug() << "RenameDialog destructor"; if(m_lineEdit) { delete m_lineEdit; m_lineEdit = NULL; } + qDebug() << "RenameDialog destroyed"; } int RenameDialog::showDialog(const QString &strReName, const QString &strAlias, bool isDirectory, bool isRepeat) @@ -644,18 +686,29 @@ int RenameDialog::showDialog(const QString &strReName, const QString &strAlias, QString RenameDialog::getNewNameText() const { - if(!m_lineEdit) return ""; + qDebug() << "Getting new name text from RenameDialog"; + if(!m_lineEdit) { + qWarning() << "Line edit is null, returning empty string"; + return ""; + } if(m_lineEdit->text().isNull() || m_lineEdit->text().isEmpty()) { + qDebug() << "No new name entered, returning original path"; return QFileInfo(m_strName).absoluteFilePath(); } if(m_isDirectory) { - return QFileInfo(m_strName).path() + QDir::separator() + m_lineEdit->text(); + QString newPath = QFileInfo(m_strName).path() + QDir::separator() + m_lineEdit->text(); + qDebug() << "New directory path:" << newPath; + return newPath; } else { QString strSuffix = QFileInfo(m_strName).suffix(); if(strSuffix.isNull() || strSuffix.isEmpty()) { - return QFileInfo(m_strName).path() + QDir::separator() + m_lineEdit->text(); + QString newPath = QFileInfo(m_strName).path() + QDir::separator() + m_lineEdit->text(); + qDebug() << "New file path (no suffix):" << newPath; + return newPath; } else { - return QFileInfo(m_strName).path() + QDir::separator() + m_lineEdit->text() +"."+ QFileInfo(m_strName).suffix(); + QString newPath = QFileInfo(m_strName).path() + QDir::separator() + m_lineEdit->text() +"."+ QFileInfo(m_strName).suffix(); + qDebug() << "New file path (with suffix):" << newPath; + return newPath; } } } diff --git a/src/source/dialog/settingdialog.cpp b/src/source/dialog/settingdialog.cpp index 104200a8..b057ab86 100644 --- a/src/source/dialog/settingdialog.cpp +++ b/src/source/dialog/settingdialog.cpp @@ -114,12 +114,14 @@ void SettingDialog::initUI() void SettingDialog::initConnections() { + qDebug() << "Initializing SettingDialog connections"; //m_setting需要setBackend,该信号才会有效 connect(m_settings, &DSettings::valueChanged, this, &SettingDialog::slotSettingsChanged); } void SettingDialog::createSettingButton() { + qDebug() << "Creating custom setting button"; this->widgetFactory()->registerWidget("custom-button", [this](QObject * obj) -> QWidget* { m_customButtonOption = qobject_cast(obj); if (m_customButtonOption) @@ -153,6 +155,7 @@ void SettingDialog::createSettingButton() void SettingDialog::createPathBox() { + qDebug() << "Creating path box"; this->widgetFactory()->registerWidget("pathbox", [this](QObject * obj) -> QWidget* { m_extractPathOption = qobject_cast(obj); if (m_extractPathOption) @@ -265,6 +268,7 @@ void SettingDialog::createPathBox() void SettingDialog::createDeleteBox() { + qDebug() << "Creating delete box"; this->widgetFactory()->registerWidget("deletebox", [this](QObject * obj) -> QWidget* { m_deleteArchiveOption = qobject_cast(obj); if (m_deleteArchiveOption) @@ -330,6 +334,7 @@ void SettingDialog::createDeleteBox() void SettingDialog::writeConfbf() { + qDebug() << "Writing configuration to file"; // 设置配置文件的绝对路径 const QString confDir = DStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); const QString confPath = confDir + QDir::separator() + "deepin-compressor.confbf"; diff --git a/src/source/dialog/settings_translation.cpp b/src/source/dialog/settings_translation.cpp index 4b16bce7..9a8e78fc 100644 --- a/src/source/dialog/settings_translation.cpp +++ b/src/source/dialog/settings_translation.cpp @@ -4,9 +4,11 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include +#include void GenerateSettingTranslate() { + // qDebug() << "Generating setting translations"; auto setting_Text = QObject::tr("General"); //设置 auto decompress = QObject::tr("Extraction"); //解压 auto create_folder = QObject::tr("Auto create a folder for multiple extracted files"); //自动创建文件夹 @@ -15,4 +17,5 @@ void GenerateSettingTranslate() auto delete_file = QObject::tr("Delete files after compression"); //压缩后删除原来的文件 auto file_association = QObject::tr("Files Associated"); //关联文件 auto file_type = QObject::tr("File Type"); //文件类型 + // qDebug() << "Setting translations generated successfully"; } diff --git a/src/source/mainwindow.cpp b/src/source/mainwindow.cpp index 55bb6835..5882a55c 100644 --- a/src/source/mainwindow.cpp +++ b/src/source/mainwindow.cpp @@ -156,6 +156,7 @@ bool MainWindow::checkHerePath(const QString &strPath) void MainWindow::initUI() { + qDebug() << "initUI"; // 初始化界面 m_pLoadingPage = new LoadingPage(this); // 加载界面 @@ -189,6 +190,7 @@ void MainWindow::initUI() void MainWindow::initTitleBar() { + qDebug() << "MainWindow::initTitleBar"; // 创建菜单 QMenu *menu = new QMenu(this); m_pOpenAction = menu->addAction(tr("Open file"), this, &MainWindow::slotChoosefiles); @@ -325,9 +327,12 @@ void MainWindow::refreshPage() m_pMainWidget->setCurrentIndex(3); bool bShowAddBtn = true; if(property(ORDER_JSON).isValid()) { + qDebug() << "property ORDER_JSON is valid"; if(m_pUnCompressPage) { + qDebug() << "m_pUnCompressPage is not null"; QVariantMap mapdata = m_pUnCompressPage->mapOrderJson(); if(mapdata.contains(ORDER_EDIT)) { + qDebug() << "mapdata contains ORDER_EDIT"; bShowAddBtn = mapdata.value(ORDER_EDIT).toBool(); m_pOpenAction->setEnabled(bShowAddBtn); } @@ -378,6 +383,7 @@ void MainWindow::refreshPage() } break; case PI_ConvertProgress: { + qDebug() << "MainWindow::refreshPage PI_ConvertProgress"; m_pMainWidget->setCurrentIndex(4); setTitleButtonStyle(false, false); m_pProgressPage->resetProgress(); @@ -385,6 +391,7 @@ void MainWindow::refreshPage() } break; case PI_CommentProgress: { + qDebug() << "MainWindow::refreshPage PI_CommentProgress"; m_pMainWidget->setCurrentIndex(4); setTitleButtonStyle(false, false); m_pProgressPage->resetProgress(); @@ -392,18 +399,21 @@ void MainWindow::refreshPage() } break; case PI_Success: { + qDebug() << "MainWindow::refreshPage PI_Success"; m_pMainWidget->setCurrentIndex(5); setTitleButtonStyle(false, false); titlebar()->setTitle(""); } break; case PI_Failure: { + qDebug() << "MainWindow::refreshPage PI_Failure"; m_pMainWidget->setCurrentIndex(6); setTitleButtonStyle(false, false); titlebar()->setTitle(""); } break; case PI_Loading: { + qDebug() << "MainWindow::refreshPage PI_Loading"; m_pMainWidget->setCurrentIndex(7); setTitleButtonStyle(false, false); titlebar()->setTitle(""); @@ -412,6 +422,7 @@ void MainWindow::refreshPage() } //压缩文件焦点需压缩文件名上 if(m_ePageID == PI_CompressSetting) { + qDebug() << "m_ePageID is PI_CompressSetting, return"; return; } //切换界面后焦点默认在标题栏上 @@ -430,6 +441,7 @@ qint64 MainWindow::calSelectedTotalFileSize(const QStringList &files) foreach (QString file, files) { QFileInfo fi(file); if (fi.isFile()) { // 如果为文件,直接获取大小 + qDebug() << "Calculate file size:" << file; qint64 curFileSize = fi.size(); #ifdef __aarch64__ @@ -439,6 +451,7 @@ qint64 MainWindow::calSelectedTotalFileSize(const QStringList &files) #endif m_stCompressParameter.qSize += curFileSize; } else if (fi.isDir()) { // 如果是文件夹,递归获取所有子文件大小总和 + qDebug() << "Calculate directory size:" << file; #if QT_VERSION < QT_VERSION_CHECK(6 ,0, 0) QtConcurrent::run(this, &MainWindow::calFileSizeByThread, file); #else @@ -502,6 +515,7 @@ void MainWindow::calFileSizeByThread(const QString &path) void MainWindow::setTitleButtonStyle(bool bVisible, bool bVisible2, DStyle::StandardPixmap pixmap) { + qDebug() << "MainWindow::setTitleButtonStyle" << bVisible << bVisible2 << pixmap; m_pTitleWidget->setVisible(bVisible || bVisible2); m_pTitleWidget->setTitleButtonStyle(bVisible, bVisible2, pixmap); } @@ -597,6 +611,7 @@ void MainWindow::loadArchive(const QString &strArchiveFullPath) void MainWindow::timerEvent(QTimerEvent *event) { + // qDebug() << "MainWindow::timerEvent" << event->timerId(); if (m_iInitUITimer == event->timerId()) { if (!m_initFlag) { // 初始化界面 @@ -656,6 +671,7 @@ void MainWindow::timerEvent(QTimerEvent *event) void MainWindow::closeEvent(QCloseEvent *event) { + // qDebug() << "MainWindow::closeEvent"; if (m_operationtype != Operation_NULL) { qDebug() << "Application close requested with ongoing operation"; // 保存当前操作的状态以便还原操作 @@ -1031,6 +1047,7 @@ void MainWindow::slotChoosefiles() // 关闭或取消不处理 if (mode != QDialog::Accepted) { + qDebug() << "File dialog canceled"; return; } @@ -1041,6 +1058,7 @@ void MainWindow::slotChoosefiles() // 判断是否是本地设备文件,过滤 手机 网络 ftp smb 等 for (const auto &url : listSelFiles) { if (!UiTools::isLocalDeviceFile(url)) { + qWarning() << "Non-local file selected, aborting:" << url; return; } @@ -1100,6 +1118,7 @@ void MainWindow::slotDragSelectedFiles(const QStringList &listFiles) void MainWindow::slotCompressLevelChanged(bool bRootIndex) { + qDebug() << "MainWindow::slotCompressLevelChanged" << bRootIndex; m_pOpenAction->setEnabled(bRootIndex); m_pTitleWidget->setTitleButtonVisible(bRootIndex); } @@ -1351,6 +1370,7 @@ void MainWindow::slotReceiveCurFileName(const QString &strName) void MainWindow::slotReceiveFileWriteErrorName(const QString &strName) { + qDebug() << "MainWindow::slotReceiveFileWriteErrorName" << strName; m_fileWriteErrorName = strName; } diff --git a/src/source/page/compresspage.cpp b/src/source/page/compresspage.cpp index 3cfd9050..45b5fd3a 100644 --- a/src/source/page/compresspage.cpp +++ b/src/source/page/compresspage.cpp @@ -71,6 +71,7 @@ void CompressPage::clear() void CompressPage::initUI() { + qInfo() << "Initializing compress page UI"; // 初始化相关变量 m_pCompressView = new CompressView(this); m_pNextBtn = new CustomPushButton(tr("Next"), this); @@ -103,6 +104,7 @@ void CompressPage::initUI() void CompressPage::initConnections() { + qInfo() << "Initializing compress page connections"; connect(m_pNextBtn, &DPushButton::clicked, this, &CompressPage::slotCompressNextClicked); connect(m_pCompressView, &CompressView::signalLevelChanged, this, &CompressPage::slotCompressLevelChanged); } @@ -113,9 +115,11 @@ void CompressPage::slotCompressNextClicked() // 如果没有待压缩文件,弹出提示框 if (m_pCompressView->getCompressFiles().isEmpty()) { + qInfo() << "No files to compress, showing tip dialog"; TipDialog dialog(this); dialog.showDialog(tr("Please add files"), tr("OK", "button")); } else { + qInfo() << "Files to compress, emit signalCompressNextClicked"; emit signalCompressNextClicked(); // 发送下一步信号 } } @@ -140,10 +144,12 @@ void CompressPage::slotFileChoose() CustomPushButton *CompressPage::getNextBtn() const { + // qInfo() << "Getting next button pointer"; return m_pNextBtn; } CompressView *CompressPage::getCompressView() { + // qInfo() << "Getting compress view pointer"; return m_pCompressView; } diff --git a/src/source/page/compresssettingpage.cpp b/src/source/page/compresssettingpage.cpp index 11ef06f6..f64125a8 100644 --- a/src/source/page/compresssettingpage.cpp +++ b/src/source/page/compresssettingpage.cpp @@ -40,23 +40,27 @@ DCORE_USE_NAMESPACE TypeLabel::TypeLabel(QWidget *parent) : DFrame(parent) { + qDebug() << "TypeLabel constructor"; setFrameShape(QFrame::NoFrame); } TypeLabel::~TypeLabel() { - + qDebug() << "TypeLabel destructor"; } void TypeLabel::mousePressEvent(QMouseEvent *event) { + qDebug() << "TypeLabel mousePressEvent"; emit labelClickEvent(event); DFrame::mousePressEvent(event); } void TypeLabel::paintEvent(QPaintEvent *event) { + // qDebug() << "TypeLabel paintEvent"; if (hasFocus() && (m_reson & (Qt::TabFocusReason | Qt::BacktabFocusReason | Qt::PopupFocusReason))) { + // qDebug() << "TypeLabel paintEvent has focus"; DStylePainter painter(this); DStyle *style = dynamic_cast(DApplication::style()); QStyleOptionFrame opt; @@ -75,12 +79,14 @@ void TypeLabel::paintEvent(QPaintEvent *event) void TypeLabel::focusInEvent(QFocusEvent *event) { + // qDebug() << "TypeLabel focusInEvent"; m_reson = event->reason(); DFrame::focusInEvent(event); } void TypeLabel::focusOutEvent(QFocusEvent *event) { + // qDebug() << "TypeLabel focusOutEvent"; m_reson = event->reason(); DFrame::focusOutEvent(event); } @@ -197,6 +203,7 @@ void CompressSettingPage::refreshMenu() void CompressSettingPage::initUI() { + qDebug() << "initUI"; // 左侧界面 m_pTypePixmapLbl = new DLabel(this); m_pClickLbl = new TypeLabel(this); @@ -385,6 +392,7 @@ void CompressSettingPage::initUI() void CompressSettingPage::initConnections() { + qDebug() << "initConnections"; connect(m_pClickLbl, SIGNAL(labelClickEvent(QMouseEvent *)), this, SLOT(slotShowRightMenu(QMouseEvent *))); connect(m_pTypeMenu, &DMenu::triggered, this, &CompressSettingPage::slotTypeChanged); connect(m_pFileNameEdt, &DLineEdit::textChanged, this, &CompressSettingPage::slotRefreshFileNameEdit); @@ -399,6 +407,7 @@ void CompressSettingPage::initConnections() void CompressSettingPage::setTypeImage(const QString &strType) { + qDebug() << "setTypeImage: " << strType; QFileIconProvider provider; QIcon icon = provider.icon(QFileInfo("temp." + strType)); @@ -412,16 +421,19 @@ bool CompressSettingPage::checkFileNameVaild(const QString &strText) // 文件名为空返回错误 if (strArchiveName.length() == 0) { + qWarning() << "File name is empty"; return false; } // 文件名过长返回错误 if (strArchiveName.length() > 255) { + qWarning() << "File name is too long"; return false; } // 如果文件名中包含"/",返回错误 if (strArchiveName.contains(QDir::separator())) { + qWarning() << "File name contains separator"; return false; } @@ -430,17 +442,20 @@ bool CompressSettingPage::checkFileNameVaild(const QString &strText) void CompressSettingPage::setEncryptedEnabled(bool bEnabled) { + qDebug() << "setEncryptedEnabled: " << bEnabled; // 设置加密是否可用 m_pEncryptedLbl->setEnabled(bEnabled); m_pPasswordEdt->setEnabled(bEnabled); if (!bEnabled) { + qDebug() << "Disabling list encryption"; setListEncryptionEnabled(bEnabled); } } void CompressSettingPage::slotEchoModeChanged(bool bEchoOn) { + qDebug() << "CompressSettingPage::slotEchoModeChanged" << bEchoOn; // 根据明暗码决定是否屏蔽输入法 m_pPasswordEdt->lineEdit()->setAttribute(Qt::WA_InputMethodEnabled, bEchoOn); } @@ -451,29 +466,35 @@ void CompressSettingPage::slotEchoModeChanged(bool bEchoOn) */ void CompressSettingPage::setListEncryptionEnabled(bool bEnabled) { + qDebug() << "setListEncryptionEnabled: " << bEnabled; m_pListEncryptionLbl->setEnabled(bEnabled); m_pListEncryptionBtn->setEnabled(bEnabled); } void CompressSettingPage::setSplitEnabled(bool bEnabled) { + qDebug() << "setSplitEnabled: " << bEnabled; m_pSplitCkb->setEnabled(bEnabled); // 设置分卷勾选框是否可用 // 如果不分卷,取消勾选,清空分卷数据 if (!bEnabled) { + qDebug() << "Disabling split"; m_pSplitCkb->setCheckState(Qt::Unchecked); m_pSplitValueEdt->setEnabled(bEnabled); m_pSplitValueEdt->clear(); m_pSplitValueEdt->setValue(0.0); } else { + qDebug() << "Enabling split"; m_pSplitValueEdt->setEnabled(m_pSplitCkb->isChecked()); } } void CompressSettingPage::refreshCompressLevel(const QString &strType) { + qDebug() << "refreshCompressLevel: " << strType; #ifdef DTKCORE_CLASS_DConfigFile if(m_isOrderMode) { + qDebug() << "Order mode is enabled"; // 其余格式支持设置压缩方式 // 设置压缩方式可用 m_pCompressLevelCmb->setEnabled(true); @@ -481,22 +502,28 @@ void CompressSettingPage::refreshCompressLevel(const QString &strType) if(!m_dconfig) return; DConfig *dconfig = (DConfig *)m_dconfig; if(strType == "7z") { + qDebug() << "Refresh compress level for 7z"; if(dconfig && dconfig->isValid() && dconfig->keyList().contains("special7zCompressor")){ + qDebug() << "Setting 7z compress level from config"; int nMethod = dconfig->value("special7zCompressor").toInt(); m_pCompressLevelCmb->setCurrentIndex(nMethod); } } else if(strType == "jar") { + qDebug() << "Refresh compress level for jar"; if(dconfig && dconfig->isValid() && dconfig->keyList().contains("specialJarCompressor")){ + qDebug() << "Setting jar compress level from config"; int nMethod = dconfig->value("specialJarCompressor").toInt(); m_pCompressLevelCmb->setCurrentIndex(nMethod); } } else if(strType == "tar") { + qDebug() << "Refresh compress level for tar"; // tar只有存储功能 m_pCompressLevelCmb->setCurrentIndex(0); // 设置压缩方式不可用 m_pCompressLevelCmb->setEnabled(false); m_pCompressLevelLbl->setEnabled(false); } else if(strType == "tar.bz2") { + qDebug() << "Refresh compress level for tar.bz2"; if(dconfig && dconfig->isValid() && dconfig->keyList().contains("specialTarbz2Compressor")){ int nMethod = dconfig->value("specialTarbz2Compressor").toInt(); m_pCompressLevelCmb->setCurrentIndex(nMethod); @@ -578,6 +605,7 @@ void CompressSettingPage::refreshCompressLevel(const QString &strType) void CompressSettingPage::setCommentEnabled(bool bEnabled) { + qDebug() << "setCommentEnabled: " << bEnabled; m_pCommentLbl->setEnabled(bEnabled); m_pCommentEdt->setEnabled(bEnabled); // 注释不可用时,清除注释 @@ -587,23 +615,28 @@ void CompressSettingPage::setCommentEnabled(bool bEnabled) bool CompressSettingPage::checkCompressOptionValid() { + qDebug() << "Checking compress options validity"; if (!checkFileNameVaild(m_pFileNameEdt->text())) { // 检查文件名是否有效 + qWarning() << "Invalid file name"; showWarningDialog(tr("Invalid file name")); return false; } QFileInfo fInfo(m_pSavePathEdt->text()); if ((m_pSavePathEdt->text().remove(" ")).isEmpty()) { // 检查是否已经选择保存路径 + qWarning() << "Save path is empty"; showWarningDialog(tr("Please enter the path")); return false; } if (!fInfo.exists()) { // 检查选择保存路径是否存在 + qWarning() << "Save path does not exist"; showWarningDialog(tr("The path does not exist, please retry")); return false; } if (!(fInfo.isWritable() && fInfo.isExecutable())) { // 检查一选择保存路径是否有权限 + qWarning() << "No write/execute permission for save path"; showWarningDialog(tr("You do not have permission to save files here, please change and retry")); return false; } @@ -612,6 +645,7 @@ bool CompressSettingPage::checkCompressOptionValid() && (fabs(m_pSplitValueEdt->value()) < std::numeric_limits::epsilon() || (((m_qFileSize / 1024 / 1024) / (m_pSplitValueEdt->value())) > 200)) && (m_strMimeType.contains("7z") || m_strMimeType.contains("zip"))) { // 最多允许分卷数量为200卷 + qWarning() << "Too many volumes requested"; showWarningDialog(tr("Too many volumes, please change and retry")); return false; } @@ -620,12 +654,14 @@ bool CompressSettingPage::checkCompressOptionValid() for (int i = 0; i < m_listFiles.count(); i++) { QFileInfo file(m_listFiles.at(i)); if (!file.exists()) { // 待压缩文件已经不存在 + qWarning() << "File to be compressed does not exist:" << file.absoluteFilePath(); bResult = false; showWarningDialog(tr("%1 does not exist on the disk, please check and try again").arg(file.absoluteFilePath()), file.absoluteFilePath()); return false; } if (!file.isReadable()) { + qWarning() << "No read permission for file to be compressed:" << file.absoluteFilePath(); bResult = false; showWarningDialog(tr("You do not have permission to compress %1").arg(file.absoluteFilePath()), file.absoluteFilePath()); return false; @@ -643,12 +679,15 @@ bool CompressSettingPage::checkCompressOptionValid() bool CompressSettingPage::checkFile(const QString &path) { + qDebug() << "Checking file access:" << path; QFileInfo fileInfo(path); if (!fileInfo.exists()) { // 待压缩文件已经不存在 if (fileInfo.isSymLink()) { + qWarning() << "Symlink target does not exist:" << path; showWarningDialog(tr("The original file of %1 does not exist, please check and try again").arg(fileInfo.absoluteFilePath()), fileInfo.absoluteFilePath()); } else { + qWarning() << "File does not exist:" << path; showWarningDialog(tr("%1 does not exist on the disk, please check and try again").arg(fileInfo.absoluteFilePath()), fileInfo.absoluteFilePath()); } @@ -656,11 +695,13 @@ bool CompressSettingPage::checkFile(const QString &path) } if (!fileInfo.isReadable()) { + qWarning() << "File not readable:" << path; showWarningDialog(tr("You do not have permission to compress %1").arg(fileInfo.absoluteFilePath()), fileInfo.absoluteFilePath()); return false; } if (fileInfo.isDir()) { + qDebug() << "Checking directory contents:" << path; QDir dir(path); // 遍历文件夹下的子文件夹 QFileInfoList listInfo = dir.entryInfoList(QDir::AllEntries | QDir::System @@ -680,6 +721,7 @@ bool CompressSettingPage::checkFile(const QString &path) int CompressSettingPage::showWarningDialog(const QString &msg, const QString &strToolTip) { + qWarning() << "Showing warning dialog:" << msg; // 使用封装好的提示对话框 TipDialog dialog(this); return dialog.showDialog(msg, tr("OK", "button"), DDialog::ButtonNormal, strToolTip); @@ -687,6 +729,7 @@ int CompressSettingPage::showWarningDialog(const QString &msg, const QString &st void CompressSettingPage::setDefaultName(const QString &strName) { + qDebug() << "Setting default archive name to:" << strName; m_pFileNameEdt->setText(strName); QLineEdit *qfilename = m_pFileNameEdt->lineEdit(); qfilename->selectAll(); @@ -695,6 +738,7 @@ void CompressSettingPage::setDefaultName(const QString &strName) void CompressSettingPage::initConfig() { + qDebug() << "Initializing config"; #ifdef DTKCORE_CLASS_DConfigFile QProcess process; process.start("dmidecode"); @@ -705,6 +749,7 @@ void CompressSettingPage::initConfig() for (const QString &line : lines) { if (line.contains("String 4", Qt::CaseInsensitive)) { m_isOrderMode = line.contains("PGUX", Qt::CaseInsensitive) || line.contains("FXK11", Qt::CaseInsensitive); + qDebug() << "Order mode detected:" << m_isOrderMode; } } process.close(); @@ -714,6 +759,7 @@ void CompressSettingPage::initConfig() void CompressSettingPage::slotShowRightMenu(QMouseEvent *e) { + qDebug() << "Showing context menu"; Q_UNUSED(e) // 设置菜单弹出位置 @@ -739,27 +785,32 @@ void CompressSettingPage::slotTypeChanged(QAction *action) m_pCpuCmb->setCurrentIndex(0); if (0 == selectType.compare("tar.7z")) { // tar.7z支持普通/列表加密,不支持分卷 + qDebug() << "Type changed to tar.7z"; setEncryptedEnabled(true); setListEncryptionEnabled(true); setSplitEnabled(false); setCommentEnabled(false); } else if (0 == selectType.compare("7z")) { // 7z支持普通/列表加密。支持分卷 + qDebug() << "Type changed to 7z"; setEncryptedEnabled(true); setListEncryptionEnabled(true); setSplitEnabled(true); setCommentEnabled(false); } else if (0 == selectType.compare("zip")) { // zip支持普通加密,不支持列表加密,支持分卷,支持注释,但不同时支持分卷和注释 + qDebug() << "Type changed to zip"; setEncryptedEnabled(true); setListEncryptionEnabled(false); setSplitEnabled(true); setCommentEnabled(!m_pSplitCkb->isChecked()); // 不同时支持分卷和注释 } else { // 其余格式不支持加密,不支持分卷 + qDebug() << "Type changed to other format:" << selectType; setEncryptedEnabled(false); setListEncryptionEnabled(false); setSplitEnabled(false); setCommentEnabled(false); if (0 == selectType.compare("tar.gz")) { + qDebug() << "Enabling CPU thread selection for tar.gz"; m_pCpuLbl->setEnabled(true); m_pCpuCmb->setEnabled(true); m_pCpuCmb->setCurrentIndex(m_pCpuCmb->count() - 1); @@ -771,6 +822,7 @@ void CompressSettingPage::slotTypeChanged(QAction *action) void CompressSettingPage::slotRefreshFileNameEdit() { + qDebug() << "Refreshing file name edit style"; DPalette plt = DPaletteHelper::instance()->palette(m_pFileNameEdt); if (!m_pFileNameEdt->text().isEmpty()) { @@ -789,6 +841,7 @@ void CompressSettingPage::slotRefreshFileNameEdit() void CompressSettingPage::slotAdvancedEnabled(bool bEnabled) { + qDebug() << "Advanced options enabled:" << bEnabled; // bug103712 滚动区域内widget高度发生变化导致页面闪动 页面变化前先设置widget大小 if (bEnabled) { m_pRightScroll->widget()->setFixedHeight(SCROLL_MAX); @@ -809,6 +862,7 @@ void CompressSettingPage::slotAdvancedEnabled(bool bEnabled) // 不启用高级选项时清空界面数据 if (!bEnabled) { + qDebug() << "Clearing advanced options"; m_pPasswordEdt->clear(); m_pListEncryptionBtn->setChecked(false); m_pSplitCkb->setChecked(false); @@ -825,6 +879,7 @@ void CompressSettingPage::slotAdvancedEnabled(bool bEnabled) if(dconfig && dconfig->isValid() && dconfig->keyList().contains("specialCpuTarGzCompressor")){ int nCpu = dconfig->value("specialCpuTarGzCompressor").toInt(); m_pCpuCmb->setCurrentIndex(nCpu); + qDebug() << "Setting CPU threads for tar.gz from config:" << nCpu; } } #endif @@ -833,6 +888,7 @@ void CompressSettingPage::slotAdvancedEnabled(bool bEnabled) void CompressSettingPage::slotSplitEdtEnabled() { + qDebug() << "Split checkbox state changed, isChecked:" << m_pSplitCkb->isChecked(); if(m_pSplitValueEdt->hasFocus() || m_pCommentEdt->hasFocus()) { parentWidget()->setFocus(); } @@ -955,8 +1011,10 @@ void CompressSettingPage::slotCompressClicked() void CompressSettingPage::slotCommentTextChanged() { + qDebug() << "Comment text changed"; QString savetext = m_pCommentEdt->toPlainText(); if (savetext.size() > MAXCOMMENTLEN) { //限制最多注释MAXCOMMENTLEN个字 + qDebug() << "Comment exceeds max length, truncating"; // 保留前MAXCOMMENTLEN个注释字符 m_pCommentEdt->setText(savetext.left(MAXCOMMENTLEN)); @@ -969,11 +1027,13 @@ void CompressSettingPage::slotCommentTextChanged() void CompressSettingPage::slotPasswordChanged() { + qDebug() << "Password text changed"; QRegularExpression reg("^[\\x00-\\x80\\x{4e00}-\\x{9fa5}]+$"); QString pwdin = m_pPasswordEdt->lineEdit()->text(); QString pwdout; if (!pwdin.isEmpty() && !reg.match(pwdin).hasMatch()) { + qDebug() << "Password contains invalid characters, filtering"; for (int i = 0; i < pwdin.length(); ++i) { if (reg.match(pwdin.at(i)).hasMatch()) { pwdout.append(pwdin.at(i)); @@ -988,11 +1048,13 @@ void CompressSettingPage::slotPasswordChanged() CustomPushButton *CompressSettingPage::getCompressBtn() const { + // qDebug() << "getCompressBtn called"; return m_pCompressBtn; } QString CompressSettingPage::getComment() const { + qDebug() << "getComment called"; // m_pCommentEdt不可用时就返回空字符串,表示该压缩格式(除zip格式外)不支持添加注释 if (nullptr != m_pCommentEdt) { return m_pCommentEdt->isEnabled() ? m_pCommentEdt->toPlainText() : QString(""); @@ -1007,6 +1069,7 @@ bool CompressSettingPage::eventFilter(QObject *watched, QEvent *event) if (QEvent::KeyPress == event->type()) { QKeyEvent *keyEvent = dynamic_cast(event); if (Qt::Key_Enter == keyEvent->key() || Qt::Key_Return == keyEvent->key()) { //响应"回车键" + // qDebug() << "Enter key pressed on type label, showing menu"; m_pTypeMenu->popup(m_pCompressTypeLbl->mapToGlobal(m_pCompressTypeLbl->pos())); // 设置菜单弹出位置 m_pTypeMenu->setFocus(); // 切换焦点 return true; @@ -1024,10 +1087,12 @@ bool CompressSettingPage::eventFilter(QObject *watched, QEvent *event) bool CompressSettingPage::isOrderMode() { + // qDebug() << "isOrderMode called, returning:" << m_isOrderMode; return m_isOrderMode; } TypeLabel *CompressSettingPage::getClickLbl() const { + // qDebug() << "getClickLbl called"; return m_pClickLbl; } diff --git a/src/source/page/progresspage.cpp b/src/source/page/progresspage.cpp index 390d9e98..91442cae 100644 --- a/src/source/page/progresspage.cpp +++ b/src/source/page/progresspage.cpp @@ -83,11 +83,13 @@ void ProgressPage::setArchiveName(const QString &strArchiveName) QString ProgressPage::archiveName() { + // qDebug() << "Getting archive name:" << m_strArchiveName; return m_strArchiveName; } void ProgressPage::setProgress(double dPercent) { + // qDebug() << "Setting progress:" << dPercent << "%"; // 添加对异常进度的判断处理 if (dPercent > 100) { qWarning() << "Invalid progress percentage:" << dPercent; @@ -117,6 +119,7 @@ void ProgressPage::setProgress(double dPercent) void ProgressPage::setCurrentFileName(const QString &strFileName) { + qInfo() << "Setting current file name:" << strFileName; QFontMetrics elideFont(m_pFileNameLbl->font()); if (PT_Compress == m_eType || PT_CompressAdd == m_eType) { // 压缩和追加压缩 @@ -136,6 +139,7 @@ void ProgressPage::setCurrentFileName(const QString &strFileName) void ProgressPage::resetProgress() { + qDebug() << "resetProgress"; // 修复取消按键默认有焦点效果 m_pCancelBtn->clearFocus(); m_pPauseContinueButton->clearFocus(); @@ -159,22 +163,26 @@ void ProgressPage::resetProgress() void ProgressPage::restartTimer() { + qDebug() << "restartTimer"; m_timer.restart(); } void ProgressPage::setPushButtonCheckable(bool a, bool b) { + qDebug() << "setPushButtonCheckable, cancel:" << a << "pause/continue:" << b; m_pCancelBtn->setEnabled(a); // 取消按钮 m_pPauseContinueButton->setEnabled(b); // 暂停继续按钮 } bool ProgressPage::isPause() { + qDebug() << "isPause"; return m_pPauseContinueButton->text() == tr("Continue", "button"); } void ProgressPage::initUI() { + qDebug() << "initUI"; // 初始化控件 m_pPixmapLbl = new DLabel(this); m_pArchiveNameLbl = new DLabel(this); @@ -262,13 +270,16 @@ void ProgressPage::initConnections() void ProgressPage::calSpeedAndRemainingTime(double &dSpeed, qint64 &qRemainingTime) { + qDebug() << "calSpeedAndRemainingTime"; if (m_qConsumeTime < 0) { + qDebug() << "Consume time is negative, restart timer"; m_timer.start(); } m_qConsumeTime += m_timer.elapsed(); if (m_qConsumeTime < 0) { + qWarning() << "Consume time is negative, reset speed and remaining time"; dSpeed = 0.0; qRemainingTime = 0; return; @@ -276,11 +287,14 @@ void ProgressPage::calSpeedAndRemainingTime(double &dSpeed, qint64 &qRemainingTi // 计算速度 if (0 == m_qConsumeTime) { + qWarning() << "Consume time is zero, set speed to 0"; dSpeed = 0.0; //处理速度 } else { if (PT_Convert == m_eType) { + qDebug() << "Calculate speed for convert type"; dSpeed = 2 * (m_qTotalSize / 1024.0 * m_iPerent / 100) / m_qConsumeTime * 1000; } else { + qDebug() << "Calculate speed for other types"; dSpeed = (m_qTotalSize / 1024.0 * m_iPerent / 100) / m_qConsumeTime * 1000; } } @@ -288,22 +302,27 @@ void ProgressPage::calSpeedAndRemainingTime(double &dSpeed, qint64 &qRemainingTi // 计算剩余时间 double sizeLeft = 0; if (PT_Convert == m_eType) { + qDebug() << "Calculate remaining size for convert type"; sizeLeft = (m_qTotalSize * 2 / 1024.0) * (100 - m_iPerent) / 100; //剩余大小 } else { + qDebug() << "Calculate remaining size for other types"; sizeLeft = (m_qTotalSize / 1024.0) * (100 - m_iPerent) / 100; //剩余大小 } if (dSpeed != 0.0) { + qDebug() << "Calculate remaining time"; qRemainingTime = qint64(sizeLeft / dSpeed); //剩余时间 } if (100 != qRemainingTime && 0 == qRemainingTime) { + qDebug() << "Remaining time is 0, set to 1"; qRemainingTime = 1; } } void ProgressPage::displaySpeedAndTime(double dSpeed, qint64 qRemainingTime) { + qDebug() << "displaySpeedAndTime"; // 计算剩余需要的小时。 qint64 hour = qRemainingTime / 3600; // 计算剩余的分钟 @@ -319,6 +338,7 @@ void ProgressPage::displaySpeedAndTime(double dSpeed, qint64 qRemainingTime) // 设置剩余时间 m_pRemainingTimeLbl->setText(tr("Time left") + ": " + hh + ":" + mm + ":" + ss); if (PT_Compress == m_eType || PT_CompressAdd == m_eType) { + qInfo() << "operation type: compress"; if (dSpeed < 1024) { // 速度小于1024k, 显示速度单位为KB/s m_pSpeedLbl->setText(tr("Speed", "compress") + ": " + QString::number(dSpeed, 'f', 2) + "KB/s"); @@ -330,18 +350,21 @@ void ProgressPage::displaySpeedAndTime(double dSpeed, qint64 qRemainingTime) m_pSpeedLbl->setText(tr("Speed", "compress") + ": " + ">300MB/s"); } } else if (PT_Delete == m_eType) { + qInfo() << "operation type: delete"; if (dSpeed < 1024) { m_pSpeedLbl->setText(tr("Speed", "delete") + ": " + QString::number(dSpeed, 'f', 2) + "KB/s"); } else { m_pSpeedLbl->setText(tr("Speed", "delete") + ": " + QString::number((dSpeed / 1024), 'f', 2) + "MB/s"); } } else if (PT_Rename == m_eType) { + qInfo() << "operation type: rename"; if (dSpeed < 1024) { m_pSpeedLbl->setText(tr("Speed", "rename") + ": " + QString::number(dSpeed, 'f', 2) + "KB/s"); } else { m_pSpeedLbl->setText(tr("Speed", "rename") + ": " + QString::number((dSpeed / 1024), 'f', 2) + "MB/s"); } } else if (PT_UnCompress == m_eType) { + qInfo() << "operation type: uncompress"; if (dSpeed < 1024) { m_pSpeedLbl->setText(tr("Speed", "uncompress") + ": " + QString::number(dSpeed, 'f', 2) + "KB/s"); } else if (dSpeed > 1024 && dSpeed < 1024 * 300) { @@ -350,6 +373,7 @@ void ProgressPage::displaySpeedAndTime(double dSpeed, qint64 qRemainingTime) m_pSpeedLbl->setText(tr("Speed", "uncompress") + ": " + ">300MB/s"); } } else if (PT_Convert == m_eType) { + qInfo() << "operation type: convert"; if (dSpeed < 1024) { m_pSpeedLbl->setText(tr("Speed", "convert") + ": " + QString::number(dSpeed, 'f', 2) + "KB/s"); } else if (dSpeed > 1024 && dSpeed < 1024 * 300) { @@ -358,6 +382,7 @@ void ProgressPage::displaySpeedAndTime(double dSpeed, qint64 qRemainingTime) m_pSpeedLbl->setText(tr("Speed", "convert") + ": " + ">300MB/s"); } } else if (PT_Comment == m_eType) { + qInfo() << "operation type: comment"; m_pSpeedLbl->setText(""); m_pRemainingTimeLbl->setText(""); } @@ -365,6 +390,7 @@ void ProgressPage::displaySpeedAndTime(double dSpeed, qint64 qRemainingTime) void ProgressPage::slotPauseClicked(bool bChecked) { + qInfo() << "Pause/continue button clicked, checked:" << bChecked; if (bChecked) { // 暂停操作 qInfo() << "Pause operation requested"; @@ -391,14 +417,19 @@ void ProgressPage::slotCancelClicked() // 对话框文字描述 QString strDesText; if (PT_Compress == m_eType) { + qInfo() << "operation type: compress"; strDesText = tr("Are you sure you want to stop the compression?"); // 是否停止压缩 } else if (PT_UnCompress == m_eType) { + qInfo() << "operation type: uncompress"; strDesText = tr("Are you sure you want to stop the decompression?"); // 是否停止解压 } else if (PT_Delete == m_eType) { + qInfo() << "operation type: delete"; strDesText = tr("Are you sure you want to stop the deletion?"); // 是否停止删除 } else if (PT_CompressAdd == m_eType) { + qInfo() << "operation type: compress add"; strDesText = tr("Are you sure you want to stop the compression?"); // 是否停止追加 } else if (PT_Convert == m_eType) { + qInfo() << "operation type: convert"; strDesText = tr("Are you sure you want to stop the conversion?"); // 是否停止转换 } @@ -413,6 +444,7 @@ void ProgressPage::slotCancelClicked() // 恢复原来状态 qInfo() << "User canceled the cancel operation"; if (!CheckedFlag) { // 原来是运行状态 + qDebug() << "Resuming operation after cancel"; emit m_pPauseContinueButton->clicked(false); } } diff --git a/src/source/page/uncompresspage.cpp b/src/source/page/uncompresspage.cpp index 27174458..c097acc0 100644 --- a/src/source/page/uncompresspage.cpp +++ b/src/source/page/uncompresspage.cpp @@ -71,37 +71,44 @@ void UnCompressPage::setDefaultUncompressPath(const QString &strPath) void UnCompressPage::refreshArchiveData() { + // qDebug() << "refreshArchiveData"; m_pUnCompressView->refreshArchiveData(); } void UnCompressPage::resizeEvent(QResizeEvent *e) { + // qDebug() << "resizeEvent"; Q_UNUSED(e) m_pUncompressPathBtn->setText(elidedExtractPath(tr("Extract to:") + m_strUnCompressPath)); } void UnCompressPage::refreshDataByCurrentPathChanged() { + qDebug() << "refreshDataByCurrentPathChanged"; m_pUnCompressView->refreshDataByCurrentPathChanged(); } void UnCompressPage::addNewFiles(const QStringList &listFiles) { + qDebug() << "addNewFiles"; m_pUnCompressView->addNewFiles(listFiles); } QString UnCompressPage::getCurPath() { + qDebug() << "getCurPath"; return m_pUnCompressView->getCurPath(); } void UnCompressPage::clear() { + qDebug() << "clear"; m_pUnCompressView->clear(); } void UnCompressPage::initUI() { + qDebug() << "initUI"; m_strUnCompressPath = "~/Desktop"; // 初始化相关变量 @@ -171,6 +178,7 @@ QString UnCompressPage::elidedExtractPath(const QString &strPath) #endif QString pathStr = strPath; if (fontSize > width()) { + qDebug() << "Path is too long, elide it"; pathStr = fontMetrics.elidedText(strPath, Qt::ElideMiddle, width());//返回一个带有省略号的字符串 } @@ -235,26 +243,32 @@ void UnCompressPage::slotUnCompressPathClicked() void UnCompressPage::slotFileChoose() { - if (m_pUnCompressView->isModifiable()) + if (m_pUnCompressView->isModifiable()) { + qDebug() << "View is modifiable, emitting signalFileChoose"; emit signalFileChoose(); + } } CustomCommandLinkButton *UnCompressPage::getUncompressPathBtn() const { + qDebug() << "getUncompressPathBtn"; return m_pUncompressPathBtn; } QVariantMap UnCompressPage::mapOrderJson() { + qDebug() << "mapOrderJson"; return m_pUnCompressView->mapOrderJson(); } CustomPushButton *UnCompressPage::getUnCompressBtn() const { + qDebug() << "getUnCompressBtn"; return m_pUnCompressBtn; } UnCompressView *UnCompressPage::getUnCompressView() const { + qDebug() << "getUnCompressView"; return m_pUnCompressView; } diff --git a/src/source/tree/compressview.cpp b/src/source/tree/compressview.cpp index da427d1d..f065636b 100644 --- a/src/source/tree/compressview.cpp +++ b/src/source/tree/compressview.cpp @@ -84,6 +84,7 @@ QStringList CompressView::getCompressFiles() QList CompressView::getEntrys() { + qDebug() << "Getting entry list"; return m_listEntry; } @@ -94,6 +95,7 @@ void CompressView::refreshCompressedFiles(bool bChanged, const QString &strFileN // 对变化的文件进行监控 if (bChanged && !QFile::exists(strFileName)) { + qDebug() << "File does not exist, removing from compress list"; m_listCompressFiles.removeOne(strFileName); } @@ -139,7 +141,9 @@ void CompressView::clear() void CompressView::mouseDoubleClickEvent(QMouseEvent *event) { + qDebug() << "Mouse double click event"; if (event->button() == Qt::MouseButton::LeftButton) { + qDebug() << "Left button double clicked"; handleDoubleClick(indexAt(event->pos())); // 双击处理 } @@ -148,11 +152,13 @@ void CompressView::mouseDoubleClickEvent(QMouseEvent *event) void CompressView::initUI() { + qDebug() << "Initializing UI"; m_pFileWatcher = new QFileSystemWatcher(this); } void CompressView::initConnections() { + qDebug() << "Initializing connections"; connect(this, &CompressView::signalDragFiles, this, &CompressView::slotDragFiles, Qt::QueuedConnection); connect(this, &CompressView::customContextMenuRequested, this, &CompressView::slotShowRightMenu); connect(m_pFileWatcher, &QFileSystemWatcher::directoryChanged, this, &CompressView::slotDirChanged); // 文件目录变化 @@ -160,6 +166,7 @@ void CompressView::initConnections() FileEntry CompressView::fileInfo2Entry(const QFileInfo &fileInfo) { + qDebug() << "Converting QFileInfo to FileEntry for" << fileInfo.filePath(); FileEntry entry; entry.strFullPath = fileInfo.filePath(); // 文件全路径 @@ -167,9 +174,11 @@ FileEntry CompressView::fileInfo2Entry(const QFileInfo &fileInfo) entry.isDirectory = fileInfo.isDir(); // 是否是文件夹 if (entry.isDirectory) { + qDebug() << "File is a directory"; // 文件夹显示子文件数目 entry.qSize = QDir(fileInfo.filePath()).entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Hidden).count(); //目录下文件数 } else { + qDebug() << "File is not a directory"; // 文件直接显示大小 entry.qSize = fileInfo.size(); } @@ -185,12 +194,15 @@ FileEntry CompressView::fileInfo2Entry(const QFileInfo &fileInfo) void CompressView::handleDoubleClick(const QModelIndex &index) { + qDebug() << "Handling double click"; m_pFileWatcher->removePath(m_strCurrentPath); // 删除目录监听 qInfo() << "gaoxiang:index.isValid()" << index.isValid(); if (index.isValid()) { + qInfo() << "index is valid"; FileEntry entry = index.data(Qt::UserRole).value(); qInfo() << "gaoxiang:entry.isDirectory" << entry.isDirectory; if (entry.isDirectory) { // 如果是文件夹,进入下一层 + qInfo() << "entry is directory"; m_pFileWatcher->removePath(m_strCurrentPath); // 删除目录监听 m_iLevel++; m_strCurrentPath = entry.strFullPath; @@ -214,6 +226,7 @@ void CompressView::handleDoubleClick(const QModelIndex &index) } } else { // 如果是文件,选择默认方式打开 + qInfo() << "entry is file"; OpenWithDialog::openWithProgram(entry.strFullPath); } } @@ -221,6 +234,7 @@ void CompressView::handleDoubleClick(const QModelIndex &index) QList CompressView::getCurrentDirFiles() { + qInfo() << "Getting current directory files, path:" << m_strCurrentPath; // 获取当前目录下所有文件信息 QFileInfoList lisfInfo = QDir(m_strCurrentPath).entryInfoList(QDir::AllEntries | QDir::System | QDir::NoDotAndDotDot | QDir::Hidden); // 获取当前目录下所有子文件 @@ -236,6 +250,7 @@ QList CompressView::getCurrentDirFiles() void CompressView::handleLevelChanged() { + qDebug() << "Handling level changed, current level:" << m_iLevel; // 发送层级变化信号,通知mainwindow是否是根目录 bool bRoot = (0 == m_iLevel ? true : false); setAcceptDrops(bRoot); @@ -246,6 +261,7 @@ QString CompressView::getPrePathByLevel(const QString &strPath) { // 若层级为0,即根目录,返回空 if (0 == m_iLevel) { + qDebug() << "Already at root level, returning empty string"; return ""; } @@ -264,10 +280,13 @@ QString CompressView::getPrePathByLevel(const QString &strPath) void CompressView::refreshDataByCurrentPath() { + qInfo() << "Refreshing data by current path, current level:" << m_iLevel; if (0 == m_iLevel) { + qDebug() << "Refreshing data at root level"; setPreLblVisible(false); m_pModel->refreshFileEntry(m_listEntry); // 数据模型刷新 } else { + qDebug() << "Refreshing data at sub level, path:" << m_strCurrentPath; m_pFileWatcher->addPath(m_strCurrentPath); // 添加目录监听 setPreLblVisible(true, getPrePathByLevel(m_strCurrentPath)); m_pModel->refreshFileEntry(getCurrentDirFiles()); // 刷新数据显示 @@ -277,9 +296,11 @@ void CompressView::refreshDataByCurrentPath() void CompressView::slotShowRightMenu(const QPoint &pos) { + qInfo() << "Showing right-click menu, position:" << pos; QModelIndex index = indexAt(pos); if (index.isValid()) { + qDebug() << "Showing right-click menu for a valid item"; m_stRightEntry = index.data(Qt::UserRole).value(); // 获取文件数据 @@ -316,8 +337,10 @@ void CompressView::slotShowRightMenu(const QPoint &pos) openMenu.addAction(tr("Select default program"), this, SLOT(slotOpenStyleClicked())); if (m_stRightEntry.isDirectory) { + qInfo() << "entry is directory"; openMenu.setEnabled(false); } else { + qInfo() << "entry is file"; // 右键-打开方式选项 QAction *pAction = nullptr; // 获取支持的打开方式列表 @@ -339,7 +362,7 @@ void CompressView::slotDeleteFile() QModelIndexList selectedIndex = selectionModel()->selectedRows(0); // 获取所有待删除的第一行index if (0 == m_iLevel) { // 如果是根目录,删除缓存文件名 - + qInfo() << "Deleting selected files at root level"; // 从内存中删除选中的文件 foreach (QModelIndex index, selectedIndex) { if (index.isValid()) { @@ -355,10 +378,11 @@ void CompressView::slotDeleteFile() m_pModel->refreshFileEntry(m_listEntry); // 刷新列表数据 } else { // 提示是否删除本地文件 - + qInfo() << "Deleting selected files at sub level"; SimpleQueryDialog dialog(this); int iResult = dialog.showDialog(tr("It will permanently delete the file(s). Are you sure you want to continue?"), tr("Cancel", "button"), DDialog::ButtonNormal, tr("Confirm", "button"), DDialog::ButtonWarning); if (1 == iResult) { // 如果点击确定,移动本地文件至回收站中 + qInfo() << "Deleting selected files at sub level, user clicked confirm"; // 从本地文件中将需要删除的文件移动到回收站中 foreach (QModelIndex index, selectedIndex) { if (index.isValid()) { @@ -373,6 +397,7 @@ void CompressView::slotDeleteFile() } } } else { // 点击关闭或者取消,不操作 + qInfo() << "Deleting selected files at sub level, user clicked cancel"; return; } } @@ -474,6 +499,7 @@ void CompressView::slotDragFiles(const QStringList &listFiles) qDebug() << "Handling drag files:" << listFiles; // 在压缩列表添加一个压缩文件 if (listFiles.count() == 1 && UiTools::isArchiveFile(listFiles.at(0)) && m_listCompressFiles.count() > 0) { + qInfo() << "Dragging archive file to compress list"; SimpleQueryDialog dialog; // 询问添加压缩文件到压缩目录或者在新窗口打开压缩文件 int ret = dialog.showDialog(tr("Do you want to add the archive to the list or open it in new window?"), tr("Cancel", "button"), DDialog::ButtonNormal, @@ -481,22 +507,27 @@ void CompressView::slotDragFiles(const QStringList &listFiles) tr("Open in new window"), DDialog::ButtonRecommend); if (1 == ret) { // 添加压缩文件到目录 + qInfo() << "user clicked confirm"; addCompressFiles(listFiles); } else if (ret == 2) { // 在新窗口打开压缩文件 + qInfo() << "user clicked open in new window"; ProcessOpenThread *p = new ProcessOpenThread; p->setProgramPath(OpenWithDialog::getProgramPathByExec("deepin-compressor")); p->setArguments(QStringList() << listFiles.at(0)); p->start(); } } else { + qInfo() << "user clicked cancel"; addCompressFiles(listFiles); } } void CompressView::slotOpenStyleClicked() { + qInfo() << "user clicked open style"; QAction *pAction = qobject_cast(sender()); if (nullptr == pAction) { + qWarning() << "Action is null, returning"; return; } @@ -516,15 +547,17 @@ void CompressView::slotOpenStyleClicked() void CompressView::slotPreClicked() { + qInfo() << "user clicked pre"; m_pFileWatcher->removePath(m_strCurrentPath); // 删除目录监听 m_iLevel--; // 目录层级减1 if (0 == m_iLevel) { // 如果返回到根目录,显示待压缩文件 + qInfo() << "user clicked pre, return to root directory"; resetLevel(); } else { // 否则传递上级目录 int iIndex = m_strCurrentPath.lastIndexOf(QDir::separator()); m_strCurrentPath = m_strCurrentPath.left(iIndex); // 当前路径截掉最后一级目录 - + qInfo() << "user clicked pre, return to parent directory"; } refreshDataByCurrentPath(); // 刷新数据 @@ -541,6 +574,7 @@ void CompressView::slotPreClicked() QModelIndex tmpindex = m_pModel->getListEntryIndex(m_vPre.back()); // 获取上层文件夹对应的QModelIndex m_vPre.pop_back(); if (tmpindex.isValid()) { + qInfo() << "user clicked pre, return to parent directory, select first row"; setCurrentIndex(tmpindex); setFocus(); //焦点丢失,需手动设置焦点 } diff --git a/src/source/tree/datamodel.cpp b/src/source/tree/datamodel.cpp index 0cf42c1b..f1c7b522 100644 --- a/src/source/tree/datamodel.cpp +++ b/src/source/tree/datamodel.cpp @@ -36,7 +36,7 @@ DataModel::~DataModel() QVariant DataModel::headerData(int section, Qt::Orientation orientation, int role) const { - qDebug() << "Getting header data for section:" << section << "role:" << role; + // qDebug() << "Getting header data for section:" << section << "role:" << role; Q_UNUSED(orientation) if (Qt::DisplayRole == role) { @@ -50,7 +50,7 @@ QVariant DataModel::headerData(int section, Qt::Orientation orientation, int rol QVariant DataModel::data(const QModelIndex &index, int role) const { - qDebug() << "Getting data for index:" << index << "role:" << role; + // qDebug() << "Getting data for index:" << index << "role:" << role; int iRow = index.row(); int iColumn = index.column(); diff --git a/src/source/tree/datatreeview.cpp b/src/source/tree/datatreeview.cpp index 7929649f..086bb285 100644 --- a/src/source/tree/datatreeview.cpp +++ b/src/source/tree/datatreeview.cpp @@ -26,23 +26,26 @@ StyleTreeViewDelegate::StyleTreeViewDelegate(QObject *parent) : QStyledItemDelegate(parent) { - + qDebug() << "StyleTreeViewDelegate destructor"; } StyleTreeViewDelegate::~StyleTreeViewDelegate() { - + qDebug() << "StyleTreeViewDelegate constructor"; } QSize StyleTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { + // qDebug() << "StyleTreeViewDelegate sizeHint"; Q_UNUSED(index); #ifdef DTKWIDGET_CLASS_DSizeMode if (DGuiApplicationHelper::instance()->isCompactMode()) { + qDebug() << "Compact mode, returning compact size hint"; return QSize(option.rect.width(), TABLE_HEIGHT_CompactMode); } else { + qDebug() << "Normal mode, returning normal size hint"; return QSize(option.rect.width(), TABLE_HEIGHT_NormalMode); } #else @@ -52,7 +55,9 @@ QSize StyleTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const void StyleTreeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + // qDebug() << "StyleTreeViewDelegate paint"; if (!index.isValid()) { + // qDebug() << "Invalid index, not painting"; QStyledItemDelegate::paint(painter, option, index); return; } @@ -161,6 +166,7 @@ DataTreeView::~DataTreeView() void DataTreeView::resetLevel() { + qDebug() << "Resetting level and path"; m_iLevel = 0; m_strCurrentPath = QDir::separator(); setPreLblVisible(false); @@ -200,6 +206,7 @@ void DataTreeView::initUI() void DataTreeView::initConnections() { + qDebug() << "Initializing DataTreeView connections"; connect(m_pHeaderView->getpreLbl(), &PreviousLabel::doubleClickedSignal, this, &DataTreeView::slotPreClicked); } @@ -214,27 +221,32 @@ void DataTreeView::resizeColumnWidth() TreeHeaderView *DataTreeView::getHeaderView() const { + // qDebug() << "Getting header view"; return m_pHeaderView; } void DataTreeView::setMapOrderJson(const QString &sJson) { + qDebug() << "Setting order JSON"; QJsonParseError error; QJsonObject metaData = QJsonDocument::fromJson(sJson.toLower().toLocal8Bit().data(), &error).object(); QVariantMap mapdata = metaData.toVariantMap(); if(mapdata.contains("permission")) { + qDebug() << "Setting order JSON permission"; m_mapOrderJson = mapdata.value("permission").toMap(); } } QVariantMap DataTreeView::mapOrderJson() { + // qDebug() << "Getting order JSON map"; return m_mapOrderJson; } void DataTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const { + // qDebug() << "Drawing row"; painter->save(); painter->setRenderHint(QPainter::Antialiasing); @@ -310,13 +322,17 @@ void DataTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option void DataTreeView::focusInEvent(QFocusEvent *event) { + // qDebug() << "Focus in event"; m_reson = event->reason(); // qInfo() << m_reson << model()->rowCount() << currentIndex(); if (Qt::BacktabFocusReason == m_reson || Qt::TabFocusReason == m_reson) { // 修复不能多选删除 + // qDebug() << "Focus in with tab or backtab"; if (model()->rowCount() > 0) { if (currentIndex().isValid()) { + // qDebug() << "Selecting current index"; m_selectionModel->select(currentIndex(), QItemSelectionModel::Select | QItemSelectionModel::Rows); } else { + // qDebug() << "Selecting first index"; QModelIndex firstModelIndex = model()->index(0, 0); m_selectionModel->select(firstModelIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows); } @@ -333,8 +349,10 @@ void DataTreeView::dragEnterEvent(QDragEnterEvent *e) // 判断是否有url if (!mime->hasUrls()) { + qDebug() << "Drag enter event without urls"; e->ignore(); } else { + qDebug() << "Drag enter event with urls"; // 判断是否是本地设备文件,过滤 手机 网络 ftp smb 等 for (const auto &url : mime->urls()) { if (!UiTools::isLocalDeviceFile(url.toLocalFile())) { @@ -357,6 +375,7 @@ void DataTreeView::dragEnterEvent(QDragEnterEvent *e) void DataTreeView::dragMoveEvent(QDragMoveEvent *e) { + qDebug() << "Drag move event with mime data:" << e->mimeData()->formats(); if(m_mapOrderJson.contains(ORDER_EDIT)) { if (m_mapOrderJson.value(ORDER_EDIT).toBool()) { e->accept(); @@ -370,6 +389,7 @@ void DataTreeView::dragMoveEvent(QDragMoveEvent *e) void DataTreeView::dropEvent(QDropEvent *e) { + qDebug() << "Drop event with mime data:" << e->mimeData()->formats(); auto *const mime = e->mimeData(); if (false == mime->hasUrls()) { @@ -412,9 +432,10 @@ void DataTreeView::resizeEvent(QResizeEvent *event) bool DataTreeView::event(QEvent *event) { + // qDebug() << "Event type:" << event->type(); switch (event->type()) { case QEvent::TouchBegin: { - + // qDebug() << "Touch begin event"; QTouchEvent *touchEvent = static_cast(event); #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) @@ -449,13 +470,14 @@ bool DataTreeView::event(QEvent *event) void DataTreeView::mouseReleaseEvent(QMouseEvent *event) { + // qDebug() << "Mouse release event"; m_isPressed = false; DTreeView::mouseReleaseEvent(event); } void DataTreeView::mouseMoveEvent(QMouseEvent *event) { - qDebug() << "Mouse move at position:" << event->pos(); + // qDebug() << "Mouse move at position:" << event->pos(); if (m_isPressed) { //最小距离为防误触和双向滑动时,只触发横向或者纵向的 int touchmindistance = 2; @@ -487,11 +509,13 @@ void DataTreeView::mouseMoveEvent(QMouseEvent *event) void DataTreeView::keyPressEvent(QKeyEvent *event) { - qDebug() << "Key pressed:" << event->key() << "modifiers:" << event->modifiers(); + // qDebug() << "Key pressed:" << event->key() << "modifiers:" << event->modifiers(); // 当前选中表格第一行,再点击Key_Up,选中返回上一层目录 if (Qt::Key_Up == event->key()) { + qDebug() << "Up key pressed"; // 当前行为0或为空文件夹时,焦点放在返回上一层目录上 if (this->currentIndex().row() == 0 || model()->rowCount() == 0) { + qDebug() << "Current row is 0 or model is empty, focusing on header"; if (m_pHeaderView->isVisiable()) { m_pHeaderView->setLabelFocus(true); m_selectionModel->clearSelection(); @@ -501,6 +525,7 @@ void DataTreeView::keyPressEvent(QKeyEvent *event) // 当前选中返回上一层目录,再点击Key_Down,选中表格第一行 if (Qt::Key_Down == event->key()) { + qDebug() << "Down key pressed"; if (m_pHeaderView->isVisiable() && m_pHeaderView->isLabelFocus() && model()->rowCount() > 0) { m_pHeaderView->setLabelFocus(false); m_selectionModel->setCurrentIndex(m_pModel->index(-1, -1), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); @@ -508,15 +533,18 @@ void DataTreeView::keyPressEvent(QKeyEvent *event) } if (Qt::Key_Delete == event->key() && m_selectionModel->selectedRows().count() > 0) { //删除键 + qDebug() << "Delete key pressed"; slotDeleteFile(); } else if (Qt::Key_M == event->key() && Qt::AltModifier == event->modifiers() && m_selectionModel->selectedRows().count() > 0) { //Alt+M组合键调用右键菜单 + qDebug() << "Alt+M key pressed"; int y = 36 * currentIndex().row() + 36 / 2; //获取选中行y坐标+行高/2,列表行高36 int x = static_cast(width() * 0.618); //比较合适的x坐标 slotShowRightMenu(QPoint(x, y)); } else if ((Qt::Key_Enter == event->key() || Qt::Key_Return == event->key()) && m_selectionModel->selectedRows().count() > 0) { //回车键以默认方式打开文件(夹) + qDebug() << "Enter key pressed"; handleDoubleClick(currentIndex()); } else { DTreeView::keyPressEvent(event); @@ -525,6 +553,7 @@ void DataTreeView::keyPressEvent(QKeyEvent *event) void DataTreeView::setPreLblVisible(bool bVisible, const QString &strPath) { + qDebug() << "setPreLblVisible" << bVisible << strPath; m_pHeaderView->getpreLbl()->setPrePath(strPath); m_pHeaderView->setPreLblVisible(bVisible); } diff --git a/src/source/tree/treeheaderview.cpp b/src/source/tree/treeheaderview.cpp index a9f48287..93c2bceb 100644 --- a/src/source/tree/treeheaderview.cpp +++ b/src/source/tree/treeheaderview.cpp @@ -23,21 +23,24 @@ PreviousLabel::PreviousLabel(TreeHeaderView *parent) : DLabel(parent) , headerView_(parent) { + qDebug() << "PreviousLabel constructor"; setFocusPolicy(Qt::TabFocus); } PreviousLabel::~PreviousLabel() { - + qDebug() << "PreviousLabel destructor"; } void PreviousLabel::setPrePath(const QString &strPath) { + qDebug() << "Setting previous path to:" << strPath; QString tmp = '/' + strPath; setToolTip(tr("Current path:") + tmp); // 悬停提示 tmp = tmp.left(tmp.lastIndexOf('/')); if (tmp.isEmpty()) { + qDebug() << "Previous path is empty"; tmp.push_front('/'); } QFontMetrics elideFont(tmp); @@ -47,23 +50,27 @@ void PreviousLabel::setPrePath(const QString &strPath) void PreviousLabel::setFocusValue(bool bFocus) { + qDebug() << "Setting focus value to:" << bFocus; focusIn_ = bFocus; } void PreviousLabel::paintEvent(QPaintEvent *e) { + // qDebug() << "PreviousLabel paint event"; QRectF rectangle(0, 0, width(), height()); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QColor bgColor; if (DGuiApplicationHelper::LightType == DGuiApplicationHelper::instance()->themeType()) { + // qDebug() << "Light theme type"; if (focusIn_) { bgColor = QColor(212, 212, 212); } else { bgColor = QColor(247, 247, 247); } } else if (DGuiApplicationHelper::DarkType == DGuiApplicationHelper::instance()->themeType()) { + // qDebug() << "Dark theme type"; if (focusIn_) { bgColor = QColor(44, 44, 44); } else { @@ -83,13 +90,16 @@ void PreviousLabel::paintEvent(QPaintEvent *e) void PreviousLabel::mouseDoubleClickEvent(QMouseEvent *event) { + qDebug() << "PreviousLabel double clicked"; emit doubleClickedSignal(); QLabel::mouseDoubleClickEvent(event); } -void PreviousLabel::enterEvent(EnterEvent *event) +void PreviousLabel::enterEvent(QEnterEvent *event) { + // qDebug() << "PreviousLabel enter event"; if(!hasFocus()) { + qDebug() << "Entering label, setting focusIn to true"; focusIn_ = true; } DLabel::enterEvent(event); @@ -98,7 +108,9 @@ void PreviousLabel::enterEvent(EnterEvent *event) void PreviousLabel::leaveEvent(QEvent *event) { + // qDebug() << "PreviousLabel leave event"; if(!hasFocus()) { + qDebug() << "Leaving label, setting focusIn to false"; focusIn_ = false; } DLabel::leaveEvent(event); @@ -107,19 +119,23 @@ void PreviousLabel::leaveEvent(QEvent *event) void PreviousLabel::focusInEvent(QFocusEvent *event) { + // qDebug() << "Focus in event, setting focusIn to true"; focusIn_ = true; DLabel::focusInEvent(event); } void PreviousLabel::focusOutEvent(QFocusEvent *event) { + // qDebug() << "Focus out event, setting focusIn to false"; focusIn_ = false; DLabel::focusOutEvent(event); } void PreviousLabel::keyPressEvent(QKeyEvent *event) { + // qDebug() << "PreviousLabel key press event, key:" << event->key(); if (Qt::Key::Key_Enter == event->key() || Qt::Key::Key_Return == event->key()) { + // qDebug() << "PreviousLabel key press event, key: Enter or Return"; clearFocus(); //返回上一级时需主动移除焦点 emit doubleClickedSignal(); } else { @@ -141,12 +157,14 @@ TreeHeaderView::TreeHeaderView(Qt::Orientation orientation, QWidget *parent) m_pPreLbl = new PreviousLabel(this); #ifdef DTKWIDGET_CLASS_DSizeMode if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) { + qDebug() << "Normal mode"; setFixedHeight(TABLE_HEIGHT_NormalMode + 2); m_pPreLbl->setFixedHeight(TABLE_HEIGHT_NormalMode); m_pPreLbl->setObjectName("gotoPreviousLabel"); m_pPreLbl->move(SCROLLMARGIN, TABLE_HEIGHT_NormalMode + 2); m_pPreLbl->hide(); } else { + qDebug() << "Compact mode"; setFixedHeight(TABLE_HEIGHT_CompactMode + 2); m_pPreLbl->setFixedHeight(TABLE_HEIGHT_CompactMode); m_pPreLbl->setObjectName("gotoPreviousLabel"); @@ -182,12 +200,14 @@ TreeHeaderView::~TreeHeaderView() QSize TreeHeaderView::sizeHint() const { + // qDebug() << "TreeHeaderView sizeHint called"; QSize size = sectionSizeFromContents(0); return QSize(size.width(), size.height() + m_spacing); } int TreeHeaderView::sectionSizeHint(int logicalIndex) const { + // qDebug() << "TreeHeaderView sectionSizeHint called with logicalIndex:" << logicalIndex; QStyleOptionHeader option; initStyleOption(&option); DStyle *style = dynamic_cast(DApplication::style()); @@ -209,6 +229,7 @@ int TreeHeaderView::sectionSizeHint(int logicalIndex) const PreviousLabel *TreeHeaderView::getpreLbl() { + qDebug() << "Getting previous label"; return m_pPreLbl; } @@ -219,14 +240,18 @@ void TreeHeaderView::setPreLblVisible(bool bVisible) #ifdef DTKWIDGET_CLASS_DSizeMode if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::NormalMode) { if (bVisible) { + qDebug() << "Setting normal mode height for visible label"; setFixedHeight(TABLE_HEIGHT_NormalMode*2 + 4); // 36+38+2 与item间隔2px } else { + qDebug() << "Setting normal mode height for hidden label"; setFixedHeight(TABLE_HEIGHT_NormalMode + 2); } } else { if (bVisible) { + qDebug() << "Setting compact mode height for visible label"; setFixedHeight(TABLE_HEIGHT_CompactMode*2 + 4); // 36+38+2 与item间隔2px } else { + qDebug() << "Setting compact mode height for hidden label"; setFixedHeight(TABLE_HEIGHT_CompactMode + 2); } } @@ -298,7 +323,7 @@ painter.restore(); */ void TreeHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const { - qDebug() << "Painting section:" << logicalIndex << "with rect:" << rect; + // qDebug() << "Painting section:" << logicalIndex << "with rect:" << rect; painter->save(); painter->setRenderHint(QPainter::Antialiasing); painter->setOpacity(1); @@ -306,8 +331,10 @@ void TreeHeaderView::paintSection(QPainter *painter, const QRect &rect, int logi QWidget *wnd = DApplication::activeWindow(); DPalette::ColorGroup cg; if (!wnd) { + // qDebug() << "Active window not found"; cg = DPalette::Inactive; } else { + // qDebug() << "Active window found"; cg = DPalette::Active; } @@ -346,6 +373,7 @@ void TreeHeaderView::paintSection(QPainter *painter, const QRect &rect, int logi painter->fillRect(hSpacingRect, hSpacingBrush); if (visualIndex(logicalIndex) > 0) { + // qDebug() << "Painting section:" << logicalIndex << "with rect:" << rect; painter->fillRect(vSpacingRect, clearBrush); painter->fillRect(vSpacingRect, vSpacingBrush); } @@ -391,7 +419,7 @@ void TreeHeaderView::paintSection(QPainter *painter, const QRect &rect, int logi void TreeHeaderView::resizeEvent(QResizeEvent *event) { - qDebug() << "Resize event, new size:" << event->size(); + // qDebug() << "Resize event, new size:" << event->size(); m_pPreLbl->setFixedWidth(event->size().width() - 2 * SCROLLMARGIN); DHeaderView::resizeEvent(event); } diff --git a/src/source/tree/uncompressview.cpp b/src/source/tree/uncompressview.cpp index 31ebb1a1..d373b3bd 100644 --- a/src/source/tree/uncompressview.cpp +++ b/src/source/tree/uncompressview.cpp @@ -70,19 +70,22 @@ void UnCompressView::refreshArchiveData() void UnCompressView::setArchivePath(const QString &strPath) { + qDebug() << "Setting archive path to:" << strPath; m_strArchive = strPath; m_strArchivePath = QFileInfo(strPath).path(); } void UnCompressView::setDefaultUncompressPath(const QString &strPath) { + qDebug() << "Setting default uncompress path to:" << strPath; m_strUnCompressPath = strPath; } void UnCompressView::mousePressEvent(QMouseEvent *event) { - qDebug() << "Mouse press event at position:" << event->pos(); + // qDebug() << "Mouse press event at position:" << event->pos(); if (event->button() == Qt::MouseButton::LeftButton) { + // qDebug() << "Mouse press event at position:" << event->pos(); m_dragPos = event->pos(); } @@ -93,8 +96,9 @@ void UnCompressView::mousePressEvent(QMouseEvent *event) void UnCompressView:: mouseMoveEvent(QMouseEvent *event) { - + // qDebug() << "Mouse move event at position:" << event->pos(); if (m_isPressed) { + // qDebug() << "Is pressed"; //最小距离为防误触和双向滑动时,只触发横向或者纵向的 int touchmindistance = 2; //最大步进距离是因为原地点按马上放开,则会出现-35~-38的不合理位移,加上每次步进距离没有那么大,所以设置为30 @@ -118,15 +122,18 @@ void UnCompressView:: mouseMoveEvent(QMouseEvent *event) QModelIndexList listSel = selectedIndexes(); if (listSel.size() < 1) { + // qDebug() << "No selected index"; return; } if (!(event->buttons() & Qt::MouseButton::LeftButton) || m_pFileDragServer) { + // qDebug() << "No left button pressed or file drag server is not null"; return; } // 曼哈顿距离处理,避免误操作 if ((event->pos() - m_dragPos).manhattanLength() < QApplication::startDragDistance()) { + // qDebug() << "Manhattan distance is less than start drag distance"; return; } @@ -138,6 +145,7 @@ void UnCompressView:: mouseMoveEvent(QMouseEvent *event) QVariant value = listSel[0].data(Qt::DecorationRole); if (value.isValid()) { + // qDebug() << "Value is valid"; if (value.type() == QVariant::Pixmap) { m_pDrag->setPixmap(qvariant_cast(value)); } else if (value.type() == QVariant::Icon) { @@ -174,11 +182,13 @@ void UnCompressView:: mouseMoveEvent(QMouseEvent *event) qInfo() << "sigdragLeave"; if (result == Qt::DropAction::CopyAction) { + // qDebug() << "Drag and drop action is CopyAction"; if (m_bDrop && m_bReceive) { extract2Path(m_strSelUnCompressPath); clearDragData(); } } else { + // qDebug() << "Drag and drop action is not CopyAction"; clearDragData(); } @@ -188,13 +198,16 @@ void UnCompressView:: mouseMoveEvent(QMouseEvent *event) void UnCompressView::clearDragData() { + qDebug() << "Clear drag data"; if (m_pDrag) { + qDebug() << "delete m_pDrag"; m_pDrag->disconnect(); // 先断开信号,防止deleteLater过程中还有有一些处理 m_pDrag->deleteLater(); m_pDrag = nullptr; } if (m_pFileDragServer) { + qDebug() << "delete m_pFileDragServer"; m_pFileDragServer->setProgress(100); m_pFileDragServer->deleteLater(); m_pFileDragServer = nullptr; @@ -209,6 +222,7 @@ void UnCompressView::mouseDoubleClickEvent(QMouseEvent *event) { qDebug() << "Mouse double click event at position:" << event->pos(); if (event->button() == Qt::MouseButton::LeftButton) { + qDebug() << "Left button double clicked"; handleDoubleClick(indexAt(event->pos())); // 双击处理 } @@ -217,11 +231,12 @@ void UnCompressView::mouseDoubleClickEvent(QMouseEvent *event) void UnCompressView::initUI() { - + qDebug() << "Initializing UnCompressView UI"; } void UnCompressView::initConnections() { + qDebug() << "Initializing UnCompressView connections"; connect(this, &UnCompressView::signalDragFiles, this, &UnCompressView::slotDragFiles, Qt::QueuedConnection); // wayland下使用Qt::QueuedConnection连接方式,防止对话框exec导致事件阻塞,图标停留在界面上 connect(this, &UnCompressView::customContextMenuRequested, this, &UnCompressView::slotShowRightMenu); connect(this, &UnCompressView::sigRenameFile, this, &UnCompressView::slotRenameFile); @@ -229,6 +244,7 @@ void UnCompressView::initConnections() qlonglong UnCompressView::calDirItemCount(const QString &strFilePath) { + qDebug() << "Calculating item count for directory:" << strFilePath; ArchiveData &stArchiveData = DataManager::get_instance().archiveData(); qlonglong qItemCount = 0; @@ -250,6 +266,7 @@ qlonglong UnCompressView::calDirItemCount(const QString &strFilePath) } } + qDebug() << "Calculated item count:" << qItemCount; return qItemCount; } @@ -258,6 +275,7 @@ void UnCompressView::handleDoubleClick(const QModelIndex &index) // qInfo() << index.data(Qt::DisplayRole); if (index.isValid()) { + qDebug() << "Double-clicked item at row:" << index.row(); FileEntry entry = index.data(Qt::UserRole).value(); if (entry.isDirectory) { // 如果是文件夹,进入下一层 @@ -291,8 +309,10 @@ void UnCompressView::handleDoubleClick(const QModelIndex &index) void UnCompressView::refreshDataByCurrentPath() { if (0 == m_iLevel) { + qDebug() << "Refreshing data at root level"; setPreLblVisible(false); } else { + qDebug() << "Refreshing data at sub level, path:" << m_strCurrentPath; QString strTempPath = m_strCurrentPath; int iIndex = strTempPath.lastIndexOf(QDir::separator()); if (iIndex > 0) @@ -302,6 +322,7 @@ void UnCompressView::refreshDataByCurrentPath() // 若缓存中找不到下一层数据,从总数据中查找并同步更新到缓存数据中 if (m_mapShowEntry.find(m_strCurrentPath) == m_mapShowEntry.end()) { + qDebug() << "Data not found in cache, path:" << m_strCurrentPath; m_mapShowEntry[m_strCurrentPath] = getCurPathFiles(); } @@ -310,15 +331,19 @@ void UnCompressView::refreshDataByCurrentPath() void UnCompressView::refreshDataByCurrentPathChanged() { + qDebug() << "Refreshing data by current path changed"; if (0 == m_strCurrentPath.compare("/")) { //当前目录是第一层 + qDebug() << "Current path is root directory"; m_mapShowEntry.clear(); refreshArchiveData(); } else { //当前目录非第一层 + qDebug() << "Current path is not root directory"; ArchiveData &stArchiveData = DataManager::get_instance().archiveData(); // 删除上一级m_mapShowEntry if (1 == m_strCurrentPath.count("/")) { //当前目录是第二层 + qDebug() << "Current path is second level directory"; // 刷新第一层文件夹子项的数目 for (int i = 0; i < stArchiveData.listRootEntry.count(); ++i) { if (stArchiveData.listRootEntry[i].isDirectory) { @@ -327,6 +352,7 @@ void UnCompressView::refreshDataByCurrentPathChanged() } m_mapShowEntry["/"] = stArchiveData.listRootEntry; } else { //当前目录是第三层及之后 + qDebug() << "Current path is third level directory"; m_mapShowEntry.remove(m_strCurrentPath.left(m_strCurrentPath.lastIndexOf("/", -2) + 1)); } @@ -349,6 +375,7 @@ void UnCompressView::refreshDataByCurrentPathChanged() // 追加时需要选中追加的文件 if (CT_Add == m_eChangeType) { + qDebug() << "Current path is not root directory, append file"; // 获取所有的追加文件的文件名 QStringList listSelName; foreach (QString strFile, m_listAddFiles) { @@ -367,8 +394,11 @@ void UnCompressView::refreshDataByCurrentPathChanged() void UnCompressView::addNewFiles(const QStringList &listFiles) { - if (listFiles.empty()) + qDebug() << "Add new files, count:" << listFiles.count(); + if (listFiles.empty()) { + qDebug() << "Add new files, list is empty"; return; + } m_listAddFiles.clear(); @@ -379,6 +409,7 @@ void UnCompressView::addNewFiles(const QStringList &listFiles) // 点击取消按钮时,不进行追加操作 if (iResult != DDialog::Accepted) { + qDebug() << "Add new files, dialog is canceled"; return; } strPassword = dialog.password(); @@ -449,8 +480,10 @@ void UnCompressView::addNewFiles(const QStringList &listFiles) } // 没有需要追加的文件时,直接返回,防止出现追加根目录的现象 - if (m_listAddFiles.isEmpty()) + if (m_listAddFiles.isEmpty()) { + qDebug() << "Add new files, list is empty"; return; + } // 去除同名称文件 m_listAddFiles = UiTools::removeSameFileName(m_listAddFiles); @@ -462,11 +495,13 @@ void UnCompressView::addNewFiles(const QStringList &listFiles) QString UnCompressView::getCurPath() { + qDebug() << "Getting current path, level:" << m_iLevel; return (0 == m_iLevel) ? "" : m_strCurrentPath; // 根目录提取时上级赋值为空 } void UnCompressView::setModifiable(bool bModifiable, bool bMultiplePassword) { + qDebug() << "Setting modifiable:" << bModifiable; m_bModifiable = bModifiable; // 压缩包数据是否可修改 m_bMultiplePassword = bMultiplePassword; // 压缩包是否支持多密码 @@ -475,11 +510,13 @@ void UnCompressView::setModifiable(bool bModifiable, bool bMultiplePassword) bool UnCompressView::isModifiable() { + qDebug() << "Checking if modifiable:" << m_bModifiable; return m_bModifiable; } void UnCompressView::clear() { + qDebug() << "Clearing UnCompressView data"; // 重置数据 m_stRightEntry = FileEntry(); m_mapShowEntry.clear(); @@ -493,6 +530,7 @@ void UnCompressView::clear() QList UnCompressView::getCurPathFiles() { + qDebug() << "Getting current path files"; ArchiveData &stArchiveData = DataManager::get_instance().archiveData(); QList listEntry; @@ -518,6 +556,7 @@ QList UnCompressView::getCurPathFiles() } } + qDebug() << "Getting current path files, count:" << listEntry.size(); // int iiii = 0; // 未使用 return listEntry; } @@ -547,6 +586,7 @@ QList UnCompressView::getCurPathFiles() QList UnCompressView::getSelEntry() { + qDebug() << "Getting selected files"; QList listSelEntry; QModelIndexList listModelIndex = selectionModel()->selectedRows(); @@ -587,6 +627,7 @@ void UnCompressView::extract2Path(const QString &strPath) void UnCompressView::calEntrySizeByParentPath(const QString &strFullPath, qint64 &qSize) { + qDebug() << "Calculating entry size by parent path:" << strFullPath; ArchiveData stArchiveData = DataManager::get_instance().archiveData(); qSize = 0; @@ -605,6 +646,7 @@ void UnCompressView::calEntrySizeByParentPath(const QString &strFullPath, qint64 void UnCompressView::slotDragFiles(const QStringList &listFiles) { + qDebug() << "Dragging files, count:" << listFiles.size(); addNewFiles(listFiles); } @@ -667,6 +709,7 @@ void UnCompressView::slotShowRightMenu(const QPoint &pos) void UnCompressView::slotExtract() { + qDebug() << "Extracting files"; // 创建文件选择对话框 DFileDialog dialog(this); dialog.setAcceptMode(DFileDialog::AcceptOpen); @@ -676,6 +719,7 @@ void UnCompressView::slotExtract() const int mode = dialog.exec(); if (mode != QDialog::Accepted) { + qDebug() << "Extracting files, dialog canceled"; return; } @@ -689,6 +733,7 @@ void UnCompressView::slotExtract() void UnCompressView::slotExtract2Here() { + qDebug() << "Extracting files to current directory"; extract2Path(m_strArchivePath); } @@ -729,13 +774,19 @@ void UnCompressView::slotDeleteFile() void UnCompressView::slotRenameFile() { - if (!m_bModifiable) return; // 压缩包数据是否可更改 + qDebug() << "Renaming files"; + if (!m_bModifiable) { + qDebug() << "Renaming files, not modifiable"; + return; // 压缩包数据是否可更改 + } + qDebug() << "Renaming files, modifiable"; // 询问重命名对话框 // 重命名数据 QList listSelEntry = getSelEntry(); // 待重命名的文件数据 // 重命名只操作单个文件 if(listSelEntry.size() != 1) { + qDebug() << "Renaming files, not single file"; return; } FileEntry &entry = listSelEntry[0]; @@ -743,13 +794,16 @@ void UnCompressView::slotRenameFile() RenameDialog dialog(this); QString strShowName; if(entry.strAlias.isEmpty() || entry.strAlias.isNull()) { + qDebug() << "Renaming files, alias is empty"; strShowName = entry.strFullPath; } else { + qDebug() << "Renaming files, alias is not empty"; strShowName = entry.strAlias; } bool isRepeat = (sender() == this); int iResult = dialog.showDialog(entry.strFileName, entry.strAlias, entry.isDirectory, isRepeat); if (1 == iResult) { + qDebug() << "Renaming files, dialog confirmed"; entry.strAlias = QFileInfo(dialog.getNewNameText()).fileName(); // 获取所有文件数据 qint64 qSize = 0; // 所有需要删除的文件总大小 @@ -764,21 +818,25 @@ void UnCompressView::slotRenameFile() m_eChangeType = CT_Rename; emit signalRenameFile(entry, qSize); } - + qDebug() << "Renaming files, dialog canceled"; } void UnCompressView::slotOpen() { + qDebug() << "Opening file or directory"; // 获取当前点击的文件 QModelIndex curIndex = currentIndex(); if (curIndex.isValid()) { + qDebug() << "Opening file or directory, valid index"; FileEntry entry = curIndex.data(Qt::UserRole).value(); if (entry.isDirectory) { + qDebug() << "Opening file or directory, directory"; // 文件夹进入下一层 handleDoubleClick(curIndex); } else { + qDebug() << "Opening file or directory, file"; // 文件 解压再用默认应用程序打开 emit signalOpenFile(entry); } @@ -787,6 +845,7 @@ void UnCompressView::slotOpen() void UnCompressView::slotOpenStyleClicked() { + qDebug() << "Opening file with selected program"; QAction *pAction = qobject_cast(sender()); if (nullptr == pAction) { return; @@ -795,6 +854,7 @@ void UnCompressView::slotOpenStyleClicked() QString strText = pAction->text(); if (tr("Select default program") == strText) { + qDebug() << "select default program"; // 用选择的应用程序打开 OpenWithDialog dialog(m_stRightEntry.strFullPath); QString str = dialog.showOpenWithDialog(OpenWithDialog::SelectType); @@ -802,6 +862,7 @@ void UnCompressView::slotOpenStyleClicked() // 发送打开信号(以xx应用打开) emit signalOpenFile(m_stRightEntry, str); } else { + qDebug() << "other program"; // 发送打开信号(以xx应用打开) emit signalOpenFile(m_stRightEntry, pAction->data().toString()); } @@ -809,11 +870,14 @@ void UnCompressView::slotOpenStyleClicked() void UnCompressView::slotPreClicked() { + qDebug() << "Pre clicked"; m_iLevel--; // 目录层级减1 if (0 == m_iLevel) { // 如果返回到根目录,显示待压缩文件 + qDebug() << "root directory"; resetLevel(); } else { // 否则传递上级目录 + qDebug() << "not root directory"; // 如果以'/'结尾,先移除最后一个'/',方便接下来截取倒数第二个'/' if (m_strCurrentPath.endsWith(QDir::separator())) { m_strCurrentPath.chop(1); @@ -836,6 +900,7 @@ void UnCompressView::slotPreClicked() QModelIndex tmpindex = m_pModel->getListEntryIndex(m_vPre.back()); // 获取上层文件夹对应的QModelIndex m_vPre.pop_back(); if (tmpindex.isValid()) { + qDebug() << "Tmp index is valid"; setCurrentIndex(tmpindex); setFocus(); //焦点丢失,需手动设置焦点 }