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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ linglong
build

# vscode
.vscode
.vscode

# AI config files
.roo/
.ruru/
.roomodes
.kilocode/
11 changes: 7 additions & 4 deletions htmltopdf/htmltopdfconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ HtmltoPdfConverter::HtmltoPdfConverter(const QString &inputPath, const QString &
, m_outputPath(outputPath)
, m_page(new QWebEnginePage)
{
qDebug() << "HtmltoPdfConverter initialized with input:" << inputPath << "output:" << outputPath;

connect(m_page.data(), &QWebEnginePage::loadFinished,
this, &HtmltoPdfConverter::loadFinished);
connect(m_page.data(), &QWebEnginePage::pdfPrintingFinished,
Expand All @@ -20,26 +22,27 @@ HtmltoPdfConverter::HtmltoPdfConverter(const QString &inputPath, const QString &

int HtmltoPdfConverter::run()
{
qDebug() << "Starting HTML to PDF conversion process";
QUrl url = QUrl::fromUserInput(m_inputPath);
qDebug() << "htmltoPdf 加载的文件路径: " << url;
qDebug() << "Loading HTML file from path:" << url;
m_page->load(url);
return QCoreApplication::exec();
}

void HtmltoPdfConverter::loadFinished(bool ok)
{
if (!ok) {
qInfo() << QString("failed to load URL '%1'").arg(m_inputPath);
qWarning() << QString("Failed to load URL '%1'").arg(m_inputPath);
QCoreApplication::exit(1);
}
qInfo() << QString("success to load URL '%1'").arg(m_inputPath);
qInfo() << QString("Successfully loaded URL '%1'").arg(m_inputPath);
m_page->printToPdf(m_outputPath);
}

void HtmltoPdfConverter::pdfPrintingFinished(const QString &filePath, bool success)
{
if (!success) {
qInfo() << QString("failed to print to output file '%1'").arg(filePath);
qWarning() << QString("Failed to print to output file '%1'").arg(filePath);
QCoreApplication::exit(1);
} else {
QCoreApplication::quit();
Expand Down
14 changes: 12 additions & 2 deletions htmltopdf/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ bool isWayland();

int main(int argc, char *argv[])
{
qDebug() << "Starting html2pdf converter application";

QApplication app(argc, argv);
QApplication::setApplicationName("html2pdf");
QApplication::setApplicationVersion("v1.0");

if (isWayland()) {
bool wayland = isWayland();
qDebug() << "Wayland environment detected:" << wayland;
if (wayland) {
// 解决klu panguV平台使用QWebEnginePage崩溃的问题,不支持gpu渲染
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-gpu");
}
// 解决__sw_64__平台使用QWebEnginePage崩溃的问题
#ifdef __sw_64__
qDebug() << "Running on __sw_64__ platform, disabling sandbox";
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--no-sandbox");
#endif

Expand All @@ -42,15 +47,20 @@ int main(int argc, char *argv[])
parser.process(QCoreApplication::arguments());

const QStringList requiredArguments = parser.positionalArguments();
if (requiredArguments.size() != 2)
qInfo() << "Input file:" << requiredArguments.at(0) << "Output PDF:" << requiredArguments.at(1);
if (requiredArguments.size() != 2) {
qCritical() << "Invalid number of arguments, expected 2 but got" << requiredArguments.size();
parser.showHelp(1);
}

qInfo() << "Creating PDF converter instance";
HtmltoPdfConverter converter(requiredArguments.at(0), requiredArguments.at(1));
return converter.run();
}

bool isWayland()
{
qDebug() << "Checking display environment";
auto e = QProcessEnvironment::systemEnvironment();
QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE"));
QString WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY"));
Expand Down
12 changes: 11 additions & 1 deletion reader/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
Application::Application(int &argc, char **argv)
: DApplication(argc, argv)
{
qDebug() << "Initializing application";
loadTranslator();
qDebug() << "Translations loaded";
setAttribute(Qt::AA_UseHighDpiPixmaps);
setApplicationName("deepin-reader");
setOrganizationName("deepin");
Expand All @@ -32,9 +34,12 @@ Application::Application(int &argc, char **argv)

Application::~Application()
{
qDebug() << "Destroying application resources";
PageRenderThread::destroyForever();
qDebug() << "Page render threads destroyed";
DBusObject::destory();
qDebug() << __FUNCTION__ << "退出应用!";
qDebug() << "DBus object destroyed";
qInfo() << "Application exiting";
}

void Application::emitSheetChanged()
Expand All @@ -44,6 +49,7 @@ void Application::emitSheetChanged()

void Application::handleQuitAction()
{
qDebug() << "Handling quit action";
QList<MainWindow *> list = MainWindow::m_list;

//倒序退出,如果取消了则停止
Expand All @@ -61,6 +67,7 @@ bool Application::notify(QObject *object, QEvent *event)
if ((object->inherits("QAbstractButton")) && (keyevent->key() == Qt::Key_Return || keyevent->key() == Qt::Key_Enter)) {
QAbstractButton *pushButton = dynamic_cast<QAbstractButton *>(object);
if (pushButton) {
qDebug() << "Simulating click for button:" << pushButton;
emit pushButton->clicked(!pushButton->isChecked());
return true;
}
Expand All @@ -75,6 +82,7 @@ bool Application::notify(QObject *object, QEvent *event)
// QPoint(0,0) 表示无法获取光标位置
if (pos != QPoint(0, 0)) {
QMouseEvent event(QEvent::MouseButtonPress, pos, Qt::RightButton, Qt::NoButton, Qt::NoModifier);
qDebug() << "Simulating right click at position:" << pos;
QCoreApplication::sendEvent(object, &event);
}
}
Expand All @@ -94,6 +102,7 @@ bool Application::notify(QObject *object, QEvent *event)
if (top_window->isWindow() && !top_window->property(NON_FIRST_ACTIVE).toBool()) {
top_window->setFocus();
top_window->setProperty(NON_FIRST_ACTIVE, true);
qDebug() << "Reset focus to top level window";
}
}
}
Expand All @@ -104,6 +113,7 @@ bool Application::notify(QObject *object, QEvent *event)
if (event->type() == QEvent::ZOrderChange ||
event->type() == QEvent::WindowActivate) {
if (DocSheet *doc = qobject_cast<DocSheet *>(object)) {
qDebug() << "Updating last operation file to:" << doc->filePath();
DocSheet::g_lastOperationFile = doc->filePath();
}
}
Expand Down
23 changes: 23 additions & 0 deletions reader/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ QList<MainWindow *> MainWindow::m_list;
MainWindow::MainWindow(QStringList filePathList, DMainWindow *parent)
: DMainWindow(parent), m_initFilePathList(filePathList)
{
qDebug() << "MainWindow constructor called with" << filePathList.size() << "files";
initBase();
initUI();

Expand Down Expand Up @@ -82,6 +83,7 @@ MainWindow::MainWindow(DocSheet *sheet, DMainWindow *parent)

MainWindow::~MainWindow()
{
qDebug() << "MainWindow destructor called";
m_list.removeOne(this);

if (m_list.count() <= 0) {
Expand All @@ -91,6 +93,7 @@ MainWindow::~MainWindow()

void MainWindow::addSheet(DocSheet *sheet)
{
qDebug() << "Adding sheet to window:" << (sheet ? sheet->filePath() : "null");
if (nullptr == m_central)
return;

Expand All @@ -99,6 +102,7 @@ void MainWindow::addSheet(DocSheet *sheet)

bool MainWindow::hasSheet(DocSheet *sheet)
{
qDebug() << "Checking if window contains sheet:" << (sheet ? sheet->filePath() : "null");
if (nullptr == m_central)
return false;

Expand All @@ -107,6 +111,7 @@ bool MainWindow::hasSheet(DocSheet *sheet)

void MainWindow::activateSheet(DocSheet *sheet)
{
qDebug() << "Activating sheet:" << (sheet ? sheet->filePath() : "null");
if (nullptr == m_central)
return;

Expand All @@ -119,6 +124,7 @@ void MainWindow::activateSheet(DocSheet *sheet)

bool MainWindow::handleClose(bool needToBeSaved)
{
qDebug() << "Handling window close, needToBeSaved:" << needToBeSaved;
if ((nullptr != m_central) && (!m_central->handleClose(needToBeSaved)))
return false;

Expand All @@ -129,6 +135,7 @@ bool MainWindow::handleClose(bool needToBeSaved)

void MainWindow::addFile(const QString &filePath)
{
qDebug() << "Adding file to window:" << filePath;
if (nullptr == m_central)
return;

Expand Down Expand Up @@ -198,6 +205,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)

void MainWindow::initUI()
{
qDebug() << "Initializing main window UI";
qDebug() << __FUNCTION__ << "正在初始化UI界面...";
m_central = new Central(this);

Expand Down Expand Up @@ -265,6 +273,7 @@ void MainWindow::initUI()

void MainWindow::setDocTabBarWidget(QWidget *widget)
{
qDebug() << "Setting doc tab bar widget:" << widget;
if (m_FullTitleWidget == nullptr) {
m_FullTitleWidget = new BaseWidget(this);

Expand All @@ -288,6 +297,7 @@ void MainWindow::onTitleAniFinished()

void MainWindow::handleMainWindowFull()
{
qDebug() << "Handling window fullscreen state";
if (m_FullTitleWidget == nullptr || m_docTabWidget == nullptr)
return;

Expand Down Expand Up @@ -324,6 +334,7 @@ void MainWindow::handleMainWindowFull()

void MainWindow::handleMainWindowExitFull()
{
qDebug() << "Handling window exit fullscreen state";
if (m_FullTitleWidget == nullptr)
return;

Expand Down Expand Up @@ -369,6 +380,7 @@ void MainWindow::setTitleBarFocusEnable(bool enable)

void MainWindow::resizeFullTitleWidget()
{
qDebug() << "Resizing full title widget";
if (m_FullTitleWidget == nullptr || m_docTabWidget == nullptr)
return;

Expand All @@ -381,6 +393,7 @@ void MainWindow::resizeFullTitleWidget()

MainWindow *MainWindow::windowContainSheet(DocSheet *sheet)
{
qDebug() << "Finding window containing sheet:" << (sheet ? sheet->filePath() : "null");
foreach (MainWindow *window, m_list) {
if (window->hasSheet(sheet)) {
return window;
Expand All @@ -392,11 +405,13 @@ MainWindow *MainWindow::windowContainSheet(DocSheet *sheet)

bool MainWindow::allowCreateWindow()
{
qDebug() << "Checking if new window can be created, current count:" << m_list.count();
return m_list.count() < 20;
}

bool MainWindow::activateSheetIfExist(const QString &filePath)
{
qDebug() << "Attempting to activate sheet for file:" << filePath;
DocSheet *sheet = DocSheet::getSheetByFilePath(filePath);

if (nullptr == sheet)
Expand All @@ -414,6 +429,7 @@ bool MainWindow::activateSheetIfExist(const QString &filePath)

MainWindow *MainWindow::createWindow(QStringList filePathList)
{
qDebug() << "Creating new window with" << filePathList.size() << "files";
qDebug() << __FUNCTION__ << "正在创建主窗口...";
int iCount = MainWindow::m_list.count(); // 获取现有窗口数目
MainWindow *pMainWindow = new MainWindow(filePathList); // 创建文档查看器对话框
Expand All @@ -430,12 +446,14 @@ MainWindow *MainWindow::createWindow(QStringList filePathList)

MainWindow *MainWindow::createWindow(DocSheet *sheet)
{
qDebug() << "Creating new window for sheet:" << (sheet ? sheet->filePath() : "null");
qDebug() << __FUNCTION__ << "创建窗口!";
return new MainWindow(sheet);
}

void MainWindow::showDefaultSize()
{
qDebug() << "Setting window default size";
QSettings settings(QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("config.conf"), QSettings::IniFormat, this);

int width = settings.value("LASTWIDTH").toInt();
Expand All @@ -450,6 +468,7 @@ void MainWindow::showDefaultSize()

void MainWindow::initDynamicLibPath()
{
qDebug() << "Initializing dynamic library paths";
qDebug() << "正在加载动态库...";
// 解析ZPD定制需求提供的库 libzpdcallback.so
LoadLibNames tmp;
Expand Down Expand Up @@ -482,11 +501,13 @@ QString MainWindow::libPath(const QString &strlib)

void MainWindow::onDelayInit()
{
qDebug() << "Performing delayed initialization";
initUI();
}

void MainWindow::initBase()
{
qDebug() << "Initializing window base resources";
qDebug() << __FUNCTION__ << "正在初始化基础资源...";

m_list.append(this);
Expand Down Expand Up @@ -518,6 +539,7 @@ void MainWindow::initBase()

void MainWindow::onUpdateTitleLabelRect()
{
qDebug() << "Updating title label rectangle";
if (nullptr == m_central)
return;

Expand All @@ -531,6 +553,7 @@ void MainWindow::onUpdateTitleLabelRect()

void MainWindow::updateOrderWidgets(const QList<QWidget *> &orderlst)
{
qDebug() << "Updating widget tab order for" << orderlst.size() << "widgets";
for (int i = 0; i < orderlst.size() - 1; i++) {
QWidget::setTabOrder(orderlst.at(i), orderlst.at(i + 1));
}
Expand Down
Loading