Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ so(cmake).sh
tests/test_output
translations/*.qm
build

# vscode
.vscode/
75 changes: 50 additions & 25 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ void showWatermark(const QString &sJson, MainWindow *w)
if(mapdata.contains("wndWatermark")) {
mapwaterMark = mapdata.value("wndWatermark").toMap();
}
if(mapwaterMark.isEmpty()) return;
if(mapwaterMark.isEmpty()) {
qDebug() << "no watermark data";
return;
}

#ifdef DTKWIDGET_CLASS_DWaterMarkHelper
auto ins = DWaterMarkHelper::instance();
Expand Down Expand Up @@ -117,8 +120,11 @@ void showWatermark(const QString &sJson, MainWindow *w)

int main(int argc, char *argv[])
{
qDebug() << "Application starting with arguments:" << QCoreApplication::arguments();

//for qt5platform-plugins load DPlatformIntegration or DPlatformIntegrationParent
if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) {
qDebug() << "Setting XDG_CURRENT_DESKTOP to Deepin";
setenv("XDG_CURRENT_DESKTOP", "Deepin", 1);
}
bool orderObject = false;
Expand All @@ -127,10 +133,11 @@ int main(int argc, char *argv[])

QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); // 使用高分屏

// 初始化DTK应用程序属性
qDebug() << "Initializing DTK application properties";
CompressorApplication app(argc, argv);
app.setOrganizationName("deepin");
app.setApplicationName("deepin-compressor");
qDebug() << "Loading application translations";
app.loadTranslator();
app.setApplicationVersion(DApplication::buildVersion(QDate::currentDate().toString("yyyyMMdd")));
app.setApplicationAcknowledgementPage("https://www.deepin.org/original/deepin-compressor/");
Expand All @@ -140,8 +147,10 @@ int main(int argc, char *argv[])
app.setApplicationDisplayName(DApplication::translate("Main", "Archive Manager"));
app.setApplicationDescription(DApplication::translate("Main", "Archive Manager is a fast and lightweight application for creating and extracting archives."));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qDebug() << "Initializing application settings for Qt5";
DApplicationSettings settings(&app);
#endif
qDebug() << "Setting up logging system";
DLogManager::registerConsoleAppender();
DLogManager::registerFileAppender();

Expand All @@ -155,7 +164,7 @@ int main(int argc, char *argv[])
app.setProductIcon(appIcon);
app.setWindowIcon(appIcon);

// 命令行参数的解析
qDebug() << "Initializing command line parser";
QCommandLineParser parser;
parser.setApplicationDescription("Deepin Compressor.");
parser.addHelpOption(); //添加帮助信息(-h,--help),这个方法由QCommandLineParser自动处理
Expand All @@ -170,67 +179,83 @@ int main(int argc, char *argv[])
QStringList newfilelist;
if(argc == 3 && QString(argv[2]).startsWith("--param="))
{
qDebug() << "Processing WPS order parameters";
orderObject = true;
QString slast = QString(argv[2]).remove(0,strlen("--param="));
//接收时需要转换为可用数据
qInfo() << "last:" << slast;
qInfo() << "Base64 encoded parameter:" << slast;
sJsonStr = QByteArray::fromBase64(slast.toLatin1().data()).data();
// sJsonStr = sList.last();
qInfo() << "json:" << sJsonStr;
qInfo() << "Decoded JSON parameter:" << sJsonStr;
QString file = argv[1];
if (file.contains("file://")) {
qDebug() << "Removing file:// prefix";
file.remove("file://");
}
newfilelist.append(file);
newfilelist.append(QString(argv[2]));
} else {
qDebug() << "Processing standard command line arguments";
parser.process(app);
foreach (QString file, parser.positionalArguments()) {
if (file.contains("file://")) {
qDebug() << "Removing file:// prefix from:" << file;
file.remove("file://");
}
newfilelist.append(file);
}
}

qInfo() << "传入参数:" << newfilelist;
qInfo() << "Final file list to process:" << newfilelist;
if (orderObject) {
//启动由wps控制,本地不做控制
qDebug() << "Removing WPS parameter from file list";
newfilelist.removeLast();
qDebug() << "WPS order object flag:" << orderObject;
}

// 创建主界面
MainWindow w;
showWatermark(sJsonStr, &w);

// 默认居中显示(使用dbus判断是否为第一个进程,第一个进程居中显示)
qDebug() << "Creating DBus adaptor and connecting to session bus";
ApplicationAdaptor adaptor(&app);
QDBusConnection dbus = QDBusConnection::sessionBus();

if(!orderObject){
qDebug() << "Registering standard DBus service";
if (dbus.registerService("com.deepin.compressor")) {
qDebug() << "DBus service registered successfully, moving window to center";
Dtk::Widget::moveToCenter(&w);
} else {
qWarning() << "Failed to register standard DBus service";
}
} else {
if (dbus.registerService("com.deepin.compressor"+QString::number(QGuiApplication::applicationPid()))) {
dbus.registerObject("/"+QString::number(QGuiApplication::applicationPid()), &app);
adaptor.setCompressFile(newfilelist.first());
Dtk::Widget::moveToCenter(&w);
w.setProperty(ORDER_JSON, sJsonStr);
qDebug() << "Registering WPS-specific DBus service";
QString serviceName = "com.deepin.compressor"+QString::number(QGuiApplication::applicationPid());
if (dbus.registerService(serviceName)) {
qDebug() << "WPS DBus service registered successfully";
QString objectPath = "/"+QString::number(QGuiApplication::applicationPid());
dbus.registerObject(objectPath, &app);
adaptor.setCompressFile(newfilelist.first());
Dtk::Widget::moveToCenter(&w);
w.setProperty(ORDER_JSON, sJsonStr);
qDebug() << "Window properties set for WPS mode";
} else {
qWarning() << "Failed to register WPS DBus service";
}
QDBusConnection dbusConnection = QDBusConnection::sessionBus();

if (dbusConnection.connect("com.wps.cryptfs"
, "/com/wps/cryptfs"
, "cryptfs.method.Type"
, "activateProcess"
, &adaptor
, SLOT(onActiveWindow(qint64))
))
qDebug() << "Connecting to WPS cryptfs DBus interface";
QDBusConnection dbusConnection = QDBusConnection::sessionBus();
if (dbusConnection.connect("com.wps.cryptfs",
"/com/wps/cryptfs",
"cryptfs.method.Type",
"activateProcess",
&adaptor,
SLOT(onActiveWindow(qint64))))
{
qInfo() << "DBus connect success!";
qInfo() << "DBus connection to WPS cryptfs established successfully";
} else {
qInfo() << "DBus connect failed!";
};
qCritical() << "Failed to connect to WPS cryptfs DBus interface";
}
}


Expand Down
18 changes: 17 additions & 1 deletion src/source/DebugTimeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,63 @@

DebugTimeManager::DebugTimeManager()
{

qDebug() << "DebugTimeManager instance created";
}

void DebugTimeManager::clear()
{
qDebug() << "Clearing all debug points";
m_MapPoint.clear();
qDebug() << "Debug points cleared";
}

void DebugTimeManager::beginPointQt(const QString &point, const QString &status)
{
qDebug() << "Begin Qt debug point:" << point << "status:" << status;
PointInfo info;
info.desc = status;
info.time = QDateTime::currentMSecsSinceEpoch();
m_MapPoint.insert(point, info);
qDebug() << "Qt debug point started";
}

void DebugTimeManager::endPointQt(const QString &point)
{
qDebug() << "End Qt debug point:" << point;
if (m_MapPoint.find(point) != m_MapPoint.end()) {
m_MapPoint[point].time = QDateTime::currentMSecsSinceEpoch() - m_MapPoint[point].time;
qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(m_MapPoint[point].time);
m_MapPoint.remove(point);
qDebug() << "Qt debug point ended successfully";
} else {
qWarning() << "Qt debug point not found:" << point;
}
}

void DebugTimeManager::beginPointLinux(const QString &point, const QString &status)

Check warning on line 49 in src/source/DebugTimeManager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'beginPointLinux' is never used.
{
qDebug() << "Begin Linux debug point:" << point << "status:" << status;
struct timeval tv;
gettimeofday(&tv, nullptr);

PointInfo info;
info.desc = status;
info.time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
m_MapPoint.insert(point, info);
qDebug() << "Linux debug point started";
}

void DebugTimeManager::endPointLinux(const QString &point)

Check warning on line 62 in src/source/DebugTimeManager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'endPointLinux' is never used.
{
qDebug() << "End Linux debug point:" << point;
if (m_MapPoint.find(point) != m_MapPoint.end()) {
struct timeval tv;
gettimeofday(&tv, nullptr);
m_MapPoint[point].time = tv.tv_sec * 1000 + tv.tv_usec / 1000 - m_MapPoint[point].time;
qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(m_MapPoint[point].time);
m_MapPoint.remove(point);
qDebug() << "Linux debug point ended successfully";
} else {
qWarning() << "Linux debug point not found:" << point;
}
}
7 changes: 5 additions & 2 deletions src/source/archivemanager/archivejob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "archivejob.h"
#include <QDebug>

Check warning on line 7 in src/source/archivemanager/archivejob.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.

ArchiveJob::ArchiveJob(QObject *parent)
: QObject(parent)
{

qDebug() << "ArchiveJob object created";
}

ArchiveJob::~ArchiveJob()
{

qDebug() << "ArchiveJob object destroyed";
}

void ArchiveJob::kill()
Expand All @@ -22,6 +23,7 @@
// 设置结束标志
m_eFinishedType = PFT_Cancel;
m_eErrorType = ET_UserCancelOpertion;
qWarning() << "Archive job cancelled by user";
finishJob();
}
}
Expand All @@ -33,6 +35,7 @@

void ArchiveJob::finishJob()
{
qDebug() << "Archive job finished with status:" << m_eFinishedType;
emit signalJobFinshed();
deleteLater();
}
Expand Down
17 changes: 16 additions & 1 deletion src/source/archivemanager/archivemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ QAtomicPointer<ArchiveManager> ArchiveManager::m_instance = nullptr;//原子指
ArchiveManager::ArchiveManager(QObject *parent)
: QObject(parent)
{

qDebug() << "ArchiveManager instance created";
}

ArchiveManager::~ArchiveManager()
{
qDebug() << "ArchiveManager instance destroyed";
SAFE_DELETE_ELE(m_pArchiveJob);
SAFE_DELETE_ELE(m_pInterface);
SAFE_DELETE_ELE(m_pTempInterface);
Expand Down Expand Up @@ -62,12 +63,15 @@ void ArchiveManager::destory_instance()

bool ArchiveManager::createArchive(const QList<FileEntry> &files, const QString &strDestination, const CompressOptions &stOptions, UiTools::AssignPluginType eType)
{
qDebug() << "Starting createArchive operation for destination:" << strDestination;
// 重新创建压缩包首先释放之前的interface
if (m_pInterface != nullptr) {
qDebug() << "Clearing previous archive interface";
delete m_pInterface;
m_pInterface = nullptr;
}
if(DFMStandardPaths::pathControl(strDestination)) {
qWarning() << "Path control check failed for destination:" << strDestination;
return false;
}
m_pTempInterface = UiTools::createInterface(strDestination, true, eType);
Expand All @@ -83,14 +87,17 @@ bool ArchiveManager::createArchive(const QList<FileEntry> &files, const QString
m_pArchiveJob = pCreateJob;
pCreateJob->start();

qInfo() << "CreateArchive operation started successfully";
return true;
}

qWarning() << "Failed to create archive interface";
return false;
}

bool ArchiveManager::loadArchive(const QString &strArchiveFullPath, UiTools::AssignPluginType eType)
{
qDebug() << "Starting loadArchive operation for file:" << strArchiveFullPath;
QJsonObject obj{
{"tid", EventLogUtils::LoadCompressFile},
{"operate", "LoadCompressFile"},
Expand All @@ -99,6 +106,7 @@ bool ArchiveManager::loadArchive(const QString &strArchiveFullPath, UiTools::Ass
EventLogUtils::get().writeLogs(obj);
// 重新加载首先释放之前的interface
if (m_pInterface != nullptr) {
qDebug() << "Clearing previous archive interface";
delete m_pInterface;
m_pInterface = nullptr;
}
Expand All @@ -115,9 +123,11 @@ bool ArchiveManager::loadArchive(const QString &strArchiveFullPath, UiTools::Ass
m_pArchiveJob = pLoadJob;
pLoadJob->start();

qInfo() << "LoadArchive operation started successfully";
return true;
}

qWarning() << "Failed to load archive interface";
return false;
}

Expand Down Expand Up @@ -456,6 +466,10 @@ void ArchiveManager::slotJobFinished()
PluginFinishType eFinishType = m_pArchiveJob->m_eFinishedType;
ErrorType eErrorType = m_pArchiveJob->m_eErrorType;

qInfo() << "Job finished - Type:" << eJobType
<< "FinishType:" << eFinishType
<< "ErrorType:" << eErrorType;

// 释放job
m_pArchiveJob->deleteLater();
m_pArchiveJob = nullptr;
Expand All @@ -466,4 +480,5 @@ void ArchiveManager::slotJobFinished()

// 释放临时记录的interface
SAFE_DELETE_ELE(m_pTempInterface);
qDebug() << "Temporary interface cleared";
}
Loading