diff --git a/.gitignore b/.gitignore index 223fa485..54998abc 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,10 @@ linglong build # vscode -.vscode \ No newline at end of file +.vscode + +# AI config files +.roo/ +.ruru/ +.roomodes +.kilocode/ \ No newline at end of file diff --git a/htmltopdf/htmltopdfconverter.cpp b/htmltopdf/htmltopdfconverter.cpp index a6158a4a..0ace6561 100644 --- a/htmltopdf/htmltopdfconverter.cpp +++ b/htmltopdf/htmltopdfconverter.cpp @@ -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, @@ -20,8 +22,9 @@ 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(); } @@ -29,17 +32,17 @@ int HtmltoPdfConverter::run() 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(); diff --git a/htmltopdf/main.cpp b/htmltopdf/main.cpp index f2ab79f1..e17f355c 100644 --- a/htmltopdf/main.cpp +++ b/htmltopdf/main.cpp @@ -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 @@ -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")); diff --git a/reader/Application.cpp b/reader/Application.cpp index c88c1674..adfc897f 100644 --- a/reader/Application.cpp +++ b/reader/Application.cpp @@ -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"); @@ -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() @@ -44,6 +49,7 @@ void Application::emitSheetChanged() void Application::handleQuitAction() { + qDebug() << "Handling quit action"; QList list = MainWindow::m_list; //倒序退出,如果取消了则停止 @@ -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(object); if (pushButton) { + qDebug() << "Simulating click for button:" << pushButton; emit pushButton->clicked(!pushButton->isChecked()); return true; } @@ -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); } } @@ -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"; } } } @@ -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(object)) { + qDebug() << "Updating last operation file to:" << doc->filePath(); DocSheet::g_lastOperationFile = doc->filePath(); } } diff --git a/reader/MainWindow.cpp b/reader/MainWindow.cpp index abeb0619..b15273b6 100755 --- a/reader/MainWindow.cpp +++ b/reader/MainWindow.cpp @@ -47,6 +47,7 @@ QList MainWindow::m_list; MainWindow::MainWindow(QStringList filePathList, DMainWindow *parent) : DMainWindow(parent), m_initFilePathList(filePathList) { + qDebug() << "MainWindow constructor called with" << filePathList.size() << "files"; initBase(); initUI(); @@ -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) { @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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); @@ -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); @@ -288,6 +297,7 @@ void MainWindow::onTitleAniFinished() void MainWindow::handleMainWindowFull() { + qDebug() << "Handling window fullscreen state"; if (m_FullTitleWidget == nullptr || m_docTabWidget == nullptr) return; @@ -324,6 +334,7 @@ void MainWindow::handleMainWindowFull() void MainWindow::handleMainWindowExitFull() { + qDebug() << "Handling window exit fullscreen state"; if (m_FullTitleWidget == nullptr) return; @@ -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; @@ -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; @@ -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) @@ -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); // 创建文档查看器对话框 @@ -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(); @@ -450,6 +468,7 @@ void MainWindow::showDefaultSize() void MainWindow::initDynamicLibPath() { + qDebug() << "Initializing dynamic library paths"; qDebug() << "正在加载动态库..."; // 解析ZPD定制需求提供的库 libzpdcallback.so LoadLibNames tmp; @@ -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); @@ -518,6 +539,7 @@ void MainWindow::initBase() void MainWindow::onUpdateTitleLabelRect() { + qDebug() << "Updating title label rectangle"; if (nullptr == m_central) return; @@ -531,6 +553,7 @@ void MainWindow::onUpdateTitleLabelRect() void MainWindow::updateOrderWidgets(const QList &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)); } diff --git a/reader/app/DBusObject.cpp b/reader/app/DBusObject.cpp index 908db61f..641cb314 100644 --- a/reader/app/DBusObject.cpp +++ b/reader/app/DBusObject.cpp @@ -30,9 +30,11 @@ DBusObject *DBusObject::s_instance = nullptr; DBusObject *DBusObject::instance() { if (nullptr == s_instance) { + qDebug() << "Creating new DBusObject instance"; s_instance = new DBusObject; } + qDebug() << "Returning DBusObject instance"; return s_instance; } @@ -46,17 +48,20 @@ void DBusObject::destory() bool DBusObject::registerOrNotify(QStringList arguments) { + qDebug() << "Registering DBus service:" << DBUS_SERVER; QDBusConnection dbus = QDBusConnection::sessionBus(); if (!dbus.registerService(DBUS_SERVER)) { + qDebug() << "Service already registered, sending notification"; QDBusInterface notification(DBUS_SERVER, DBUS_SERVER_PATH, DBUS_SERVER, QDBusConnection::sessionBus()); QList args; args.append(arguments); QString error = notification.callWithArgumentList(QDBus::Block, "handleFiles", args).errorMessage(); if (!error.isEmpty()) - qInfo() << error; + qWarning() << "DBus notification error:" << error; return false; } + qDebug() << "Registering DBus object path:" << DBUS_SERVER_PATH; dbus.registerObject(DBUS_SERVER_PATH, this, QDBusConnection::ExportScriptableSlots); const QString gestureSignal = "Event"; @@ -76,22 +81,29 @@ bool DBusObject::registerOrNotify(QStringList arguments) void DBusObject::unRegister() { + qDebug() << "Unregistering DBus service:" << DBUS_SERVER; QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.unregisterService(DBUS_SERVER); } void DBusObject::blockShutdown() { - if (m_isBlockShutdown) + if (m_isBlockShutdown) { + qDebug() << "Shutdown already blocked"; return; + } if (m_blockShutdownReply.value().isValid()) { + qDebug() << "Valid shutdown block already exists"; return; } - if (m_blockShutdownInterface == nullptr) + if (m_blockShutdownInterface == nullptr) { + qDebug() << "Creating shutdown block interface"; m_blockShutdownInterface = new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus()); + } + qDebug() << "Blocking system shutdown"; QList args; args << QString("shutdown") // what << qApp->applicationDisplayName() // who @@ -100,10 +112,11 @@ void DBusObject::blockShutdown() m_blockShutdownReply = m_blockShutdownInterface->callWithArgumentList(QDBus::Block, "Inhibit", args); if (m_blockShutdownReply.isValid()) { + qDebug() << "Shutdown blocked successfully"; m_blockShutdownReply.value().fileDescriptor(); m_isBlockShutdown = true; } else { - qInfo() << m_blockShutdownReply.error(); + qWarning() << "Failed to block shutdown:" << m_blockShutdownReply.error(); } } @@ -117,30 +130,41 @@ void DBusObject::unBlockShutdown() void DBusObject::handleFiles(QStringList filePathList) { + qDebug() << "Handling files via DBus, count:" << filePathList.count(); if (filePathList.count() <= 0) { + qDebug() << "No files provided, creating empty window"; MainWindow::createWindow()->show(); return; } MainWindow *mainwindow = MainWindow::m_list.count() > 0 ? MainWindow::m_list[0] : MainWindow::createWindow(); + qDebug() << "Using main window:" << mainwindow; mainwindow->setProperty("loading", true); + foreach (QString filePath, filePathList) { + qDebug() << "Processing file:" << filePath; QUrl url(filePath); if (url.isLocalFile()) { filePath = url.toLocalFile(); + qDebug() << "Converted to local path:" << filePath; } - if (mainwindow->property("windowClosed").toBool()) + if (mainwindow->property("windowClosed").toBool()) { + qDebug() << "Window closed, stopping file processing"; break; + } - //如果存在则活跃该窗口 if (!MainWindow::activateSheetIfExist(filePath)) { + qDebug() << "Adding new file to window"; mainwindow->setWindowState((MainWindow::m_list[0]->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); mainwindow->addFile(filePath); + } else { + qDebug() << "File already open in existing window"; } } mainwindow->setProperty("loading", false); + qDebug() << "Finished processing all files"; } DBusObject::DBusObject(QObject *parent) : QObject(parent) @@ -150,9 +174,12 @@ DBusObject::DBusObject(QObject *parent) : QObject(parent) DBusObject::~DBusObject() { + qDebug() << "Destroying DBusObject"; m_blockShutdownReply = QDBusReply(); m_isBlockShutdown = false; - if (nullptr != m_blockShutdownInterface) + if (nullptr != m_blockShutdownInterface) { + qDebug() << "Cleaning up shutdown block interface"; delete m_blockShutdownInterface; + } } diff --git a/reader/app/Database.cpp b/reader/app/Database.cpp index 9edf9f21..c7d1b6bb 100644 --- a/reader/app/Database.cpp +++ b/reader/app/Database.cpp @@ -20,8 +20,9 @@ Transaction::Transaction(QSqlDatabase &database) : m_committed(false), m_database(database) { + qDebug() << "Starting database transaction"; if (!m_database.transaction()) { - qInfo() << m_database.lastError(); + qWarning() << "Failed to start transaction:" << m_database.lastError(); } } @@ -36,7 +37,11 @@ Transaction::~Transaction() void Transaction::commit() { + qDebug() << "Committing transaction"; m_committed = m_database.commit(); + if (!m_committed) { + qWarning() << "Failed to commit transaction:" << m_database.lastError(); + } } @@ -45,9 +50,11 @@ Database *Database::s_instance = nullptr; Database *Database::instance() { if (s_instance == nullptr) { + qDebug() << "Creating new Database instance"; s_instance = new Database(qApp); } + qDebug() << "Returning Database instance"; return s_instance; } @@ -61,6 +68,7 @@ bool Database::prepareOperation() { Transaction transaction(m_database); + qDebug() << "Preparing operation table"; QSqlQuery query(m_database); if (!query.exec("CREATE TABLE operation " "(filePath TEXT primary key" @@ -90,10 +98,13 @@ bool Database::readOperation(DocSheet *sheet) if(!sheet) return false; + qDebug() << "Reading operation for file:" << sheet->filePath(); QSqlQuery query(m_database); query.prepare(" select * from operation where filePath = :filePath"); query.bindValue(":filePath", sheet->filePath()); - query.exec(); + if (!query.exec()) { + qWarning() << "Failed to read operation:" << query.lastError(); + } if (query.next()) { sheet->m_operation.layoutMode = static_cast(query.value("layoutMode").toInt()); sheet->m_operation.mouseShape = static_cast(query.value("mouseShape").toInt()); @@ -136,11 +147,12 @@ bool Database::saveOperation(DocSheet *sheet) bool Database::prepareBookmark() { + qDebug() << "Preparing bookmark table"; Transaction transaction(m_database); QSqlQuery query(m_database); if (!query.exec("CREATE TABLE bookmark(filePath TEXT,bookmarkIndex INTEGER)")) { - qInfo() << query.lastError(); + qWarning() << "Failed to create bookmark table:" << query.lastError(); return false; } @@ -226,24 +238,28 @@ bool Database::saveBookmarks(const QString &filePath, const QSet bookmarks) Database::Database(QObject *parent) : QObject(parent) { + qDebug() << "Initializing database connection"; const QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + qDebug() << "Database path:" << path; QDir().mkpath(path); m_database = QSqlDatabase::addDatabase("QSQLITE"); m_database.setDatabaseName(QDir(path).filePath("user.db")); + qDebug() << "Opening database:" << m_database.databaseName(); if (!m_database.open()) { - qInfo() << m_database.lastError(); + qCritical() << "Failed to open database:" << m_database.lastError(); } if (m_database.isOpen()) { + qDebug() << "Setting database optimization parameters"; { QSqlQuery query(m_database); if (!query.exec("PRAGMA synchronous = OFF")) { - qInfo() << query.lastError(); + qWarning() << "Failed to set synchronous mode:" << query.lastError(); } if (!query.exec("PRAGMA journal_mode = MEMORY")) { - qInfo() << query.lastError(); + qWarning() << "Failed to set journal mode:" << query.lastError(); } } diff --git a/reader/app/DebugTimeManager.cpp b/reader/app/DebugTimeManager.cpp index f6b8f3f6..21db5226 100644 --- a/reader/app/DebugTimeManager.cpp +++ b/reader/app/DebugTimeManager.cpp @@ -11,16 +11,18 @@ DebugTimeManager *DebugTimeManager::s_Instance = nullptr; DebugTimeManager::DebugTimeManager() { - + qDebug() << "DebugTimeManager initialized"; } void DebugTimeManager::clear() { + qDebug() << "Clearing all debug time points"; m_MapPoint.clear(); } void DebugTimeManager::beginPointQt(const QString &point, const QString &status) { + qDebug() << "Starting Qt time point:" << point << "status:" << status; PointInfo info; info.desc = status; info.time = QDateTime::currentMSecsSinceEpoch(); @@ -29,20 +31,27 @@ void DebugTimeManager::beginPointQt(const QString &point, const QString &status) void DebugTimeManager::endPointQt(const QString &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); + qint64 elapsed = QDateTime::currentMSecsSinceEpoch() - m_MapPoint[point].time; + qDebug() << "Ending Qt time point:" << point << "elapsed:" << elapsed << "ms"; + m_MapPoint[point].time = elapsed; + qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(elapsed); m_MapPoint.remove(point); + } else { + qWarning() << "Time point not found:" << point; } } void DebugTimeManager::beginPointLinux(const QString &point, const QString &status) { + qDebug() << "Starting Linux time point:" << point << "status:" << status; struct timeval tv; gettimeofday(&tv, nullptr); + qint64 currentTime = tv.tv_sec * 1000 + tv.tv_usec / 1000; + qDebug() << "Current Linux time:" << currentTime << "ms"; PointInfo info; info.desc = status; - info.time = tv.tv_sec * 1000 + tv.tv_usec / 1000; + info.time = currentTime; m_MapPoint.insert(point, info); } void DebugTimeManager::endPointLinux(const QString &point, const QString &status) @@ -50,10 +59,18 @@ void DebugTimeManager::endPointLinux(const QString &point, const QString &statu 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; - if (!status.isEmpty()) + qint64 currentTime = tv.tv_sec * 1000 + tv.tv_usec / 1000; + qint64 elapsed = currentTime - m_MapPoint[point].time; + qDebug() << "Ending Linux time point:" << point << "elapsed:" << elapsed << "ms"; + + m_MapPoint[point].time = elapsed; + if (!status.isEmpty()) { + qDebug() << "Updating status to:" << status; m_MapPoint[point].desc = status; - qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(m_MapPoint[point].time); + } + qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(elapsed); m_MapPoint.remove(point); + } else { + qWarning() << "Time point not found:" << point; } } diff --git a/reader/app/Global.cpp b/reader/app/Global.cpp index c20b1a2f..04c94467 100644 --- a/reader/app/Global.cpp +++ b/reader/app/Global.cpp @@ -13,26 +13,37 @@ namespace Dr { FileType fileType(const QString &filePath) { + qDebug() << "Detecting file type for:" << filePath; FileType fileType = FileType::Unknown; //具体的MIME文件类型可以参考https://baike.baidu.com/item/MIME/2900607?fr=aladdin const QMimeType mimeType = QMimeDatabase().mimeTypeForFile(filePath, QMimeDatabase::MatchContent); - qInfo() << "当前文件的MIME类型: " << mimeType.name(); + qInfo() << "File MIME type:" << mimeType.name(); + qDebug() << "Matching file type..."; if (mimeType.name() == QLatin1String("application/pdf")) { + qDebug() << "Matched PDF file type"; fileType = PDF; } else if (mimeType.name() == QLatin1String("application/postscript")) { + qDebug() << "Matched PS file type"; fileType = PS; } else if (mimeType.name() == QLatin1String("image/vnd.djvu") || mimeType.name() == QLatin1String("image/vnd.djvu+multipage")) { + qDebug() << "Matched DJVU file type"; fileType = DJVU; } else if (mimeType.name() == QLatin1String("application/zip") && filePath.right(4) == "pptx") { + qDebug() << "Matched PPTX file type"; fileType = PPTX; } else if (mimeType.name() == QLatin1String("application/zip") && filePath.right(4) == "docx") { + qDebug() << "Matched DOCX file type (zip)"; fileType = DOCX; } else if (mimeType.name() == QLatin1String("application/x-ole-storage") && filePath.right(4) == "docx") { + qDebug() << "Matched DOCX file type (ole)"; fileType = DOCX; + } else { + qDebug() << "Unknown file type"; } + qDebug() << "Final file type:" << static_cast(fileType); return fileType; } diff --git a/reader/app/TMFunctionThread.cpp b/reader/app/TMFunctionThread.cpp index a98d5e18..b1200e4c 100644 --- a/reader/app/TMFunctionThread.cpp +++ b/reader/app/TMFunctionThread.cpp @@ -7,15 +7,19 @@ TMFunctionThread::TMFunctionThread(QObject *parent) : QThread(parent) { - + qDebug() << "Function thread created"; } TMFunctionThread::~TMFunctionThread() { + qDebug() << "Destroying function thread"; this->wait(); + qDebug() << "Function thread destroyed"; } void TMFunctionThread::run() { + qDebug() << "Function thread started running"; result = func(); + qDebug() << "Function execution completed, result:" << result; } diff --git a/reader/app/Utils.cpp b/reader/app/Utils.cpp index 10bc0701..e2cb95d5 100644 --- a/reader/app/Utils.cpp +++ b/reader/app/Utils.cpp @@ -30,6 +30,7 @@ int Utils::m_colorIndex = 0; QString Utils::m_currenFilePath = ""; QString Utils::getKeyshortcut(QKeyEvent *keyEvent) { + qDebug() << "Processing keyboard shortcut"; QStringList keys; Qt::KeyboardModifiers modifiers = keyEvent->modifiers(); if (modifiers != Qt::NoModifier) { @@ -59,6 +60,7 @@ QString Utils::getKeyshortcut(QKeyEvent *keyEvent) QString Utils::getInputDataSize(const qint64 &dSize) { + qDebug() << "Formatting data size:" << dSize; if (dSize < 1024) { return QString("%1 B").arg(dSize); } @@ -94,6 +96,7 @@ QPixmap Utils::roundQPixmap(const QPixmap &img_in, int radius) void Utils::copyText(const QString &sText) { + qDebug() << "Copying text to clipboard"; #if _ZPD_ int intercept = 0; if (getLoadLibsInstance()->m_document_clip_copy) { @@ -129,11 +132,15 @@ QString Utils::getElidedText(const QFontMetrics &fontMetrics, const QSize &size, bool Utils::copyFile(const QString &sourcePath, const QString &destinationPath) { - if (sourcePath == destinationPath) + qDebug() << "Copying file from:" << sourcePath << "to:" << destinationPath; + if (sourcePath == destinationPath) { + qDebug() << "Source and destination paths are the same"; return true; + } QFile sourceFile(sourcePath); if (!sourceFile.open(QIODevice::ReadOnly)) { + qWarning() << "Failed to open source file for reading"; return false; } @@ -171,6 +178,7 @@ bool Utils::copyFile(const QString &sourcePath, const QString &destinationPath) QImage Utils::copyImage(const QImage &srcimg, int x, int y, int w, int h) { + qDebug() << "Copying image region:" << QRect(x, y, w, h); int dx = 0; int dy = 0; if (w <= 0 || h <= 0) @@ -297,6 +305,7 @@ void Utils::setObjectNoFocusPolicy(QObject *obj) bool Utils::isWayland() { + qDebug() << "Checking for Wayland environment"; auto e = QProcessEnvironment::systemEnvironment(); QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE")); QString WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY")); @@ -310,5 +319,6 @@ bool Utils::isWayland() void Utils::setCurrentFilePath(QString currentFilePath) { + qDebug() << "Setting current file path:" << currentFilePath; m_currenFilePath = currentFilePath; } diff --git a/reader/app/eventlogutils.cpp b/reader/app/eventlogutils.cpp index d3e612ea..89723be8 100644 --- a/reader/app/eventlogutils.cpp +++ b/reader/app/eventlogutils.cpp @@ -15,29 +15,46 @@ EventLogUtils *EventLogUtils::mInstance(nullptr); EventLogUtils &EventLogUtils::get() { if (mInstance == nullptr) { + qDebug() << "Creating new EventLogUtils instance"; mInstance = new EventLogUtils; } + qDebug() << "Returning EventLogUtils instance"; return *mInstance; } EventLogUtils::EventLogUtils() { + qDebug() << "Loading event log library"; QLibrary library("libdeepin-event-log.so"); - init =reinterpret_cast(library.resolve("Initialize")); + qDebug() << "Resolving Initialize function"; + init = reinterpret_cast(library.resolve("Initialize")); + qDebug() << "Resolving WriteEventLog function"; writeEventLog = reinterpret_cast(library.resolve("WriteEventLog")); - if (init == nullptr) + if (init == nullptr) { + qWarning() << "Failed to resolve Initialize function"; return; + } - init("deepin-reader", true); + qDebug() << "Initializing event log for deepin-reader"; + if (!init("deepin-reader", true)) { + qWarning() << "Failed to initialize event log"; + } else { + qDebug() << "Event log initialized successfully"; + } } void EventLogUtils::writeLogs(QJsonObject &data) { - if (writeEventLog == nullptr) + if (writeEventLog == nullptr) { + qWarning() << "WriteEventLog function not available"; return; + } - //std::string str = QJsonDocument(data).toJson(QJsonDocument::Compact).toStdString(); - writeEventLog(QJsonDocument(data).toJson(QJsonDocument::Compact).toStdString()); + qDebug() << "Writing event log data"; + QByteArray jsonData = QJsonDocument(data).toJson(QJsonDocument::Compact); + qDebug() << "Event log content:" << jsonData; + writeEventLog(jsonData.toStdString()); + qDebug() << "Event log written successfully"; } diff --git a/reader/browser/BrowserAnnotation.cpp b/reader/browser/BrowserAnnotation.cpp index 1f1fbac7..d35e9c2c 100644 --- a/reader/browser/BrowserAnnotation.cpp +++ b/reader/browser/BrowserAnnotation.cpp @@ -7,6 +7,7 @@ #include "BrowserPage.h" #include +#include #include #include @@ -14,8 +15,12 @@ BrowserAnnotation::BrowserAnnotation(QGraphicsItem *parent, QRectF rect, deepin_reader::Annotation *annotation, qreal scalefactor) : QGraphicsItem(parent), m_annotation(annotation), m_rect(rect), m_parent(parent), m_scaleFactor(scalefactor) { - if (nullptr == m_annotation) + if (nullptr == m_annotation) { + qWarning() << "BrowserAnnotation: Invalid annotation pointer"; return; + } + + qDebug() << "BrowserAnnotation created, type:" << m_annotation->type(); if (m_annotation->type() == deepin_reader::Annotation::AText) setZValue(deepin_reader::Z_ORDER_ICON); @@ -25,6 +30,7 @@ BrowserAnnotation::BrowserAnnotation(QGraphicsItem *parent, QRectF rect, deepin_ BrowserAnnotation::~BrowserAnnotation() { + qDebug() << "BrowserAnnotation destroyed"; m_annotation = nullptr; } @@ -50,6 +56,7 @@ QRectF BrowserAnnotation::boundingRect() const m_rect.y() * m_scaleFactor, m_rect.width() * m_scaleFactor, m_rect.height() * m_scaleFactor); + qDebug() << "BrowserAnnotation::paint - end"; } void BrowserAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) @@ -73,6 +80,7 @@ bool BrowserAnnotation::isSame(Annotation *annotation) void BrowserAnnotation::setDrawSelectRect(const bool draw) { + qDebug() << "BrowserAnnotation::setDrawSelectRect:" << draw; if (nullptr != m_annotation && m_annotation->type() != 1) { m_drawSelectRect = false; update(); diff --git a/reader/browser/BrowserMagniFier.cpp b/reader/browser/BrowserMagniFier.cpp index 6bc7a5b2..86e3807d 100644 --- a/reader/browser/BrowserMagniFier.cpp +++ b/reader/browser/BrowserMagniFier.cpp @@ -9,6 +9,7 @@ #include "Application.h" #include +#include #include #include #include @@ -16,19 +17,23 @@ ReadMagnifierManager::ReadMagnifierManager(QWidget *parent) : QThread(parent) { + qDebug() << "ReadMagnifierManager created"; m_parent = parent; } ReadMagnifierManager::~ReadMagnifierManager() { + qDebug() << "ReadMagnifierManager destroyed"; this->wait(); } void ReadMagnifierManager::addTask(const MagnifierInfo_t &task) { + qDebug() << "ReadMagnifierManager::addTask"; m_tTasklst << task; if (!this->isRunning()) { + qInfo() << "Starting ReadMagnifierManager thread"; this->start(); } } @@ -51,6 +56,7 @@ void ReadMagnifierManager::run() BrowserMagniFier::BrowserMagniFier(SheetBrowser *parent) : QLabel(parent) { + qDebug() << "BrowserMagniFier created"; m_readManager = new ReadMagnifierManager(this); m_brwoser = parent; @@ -70,11 +76,13 @@ BrowserMagniFier::BrowserMagniFier(SheetBrowser *parent) BrowserMagniFier::~BrowserMagniFier() { + qDebug() << "BrowserMagniFier destroyed"; m_readManager->wait(); } void BrowserMagniFier::updateImage() { + qDebug() << "BrowserMagniFier::updateImage"; QPointF point = m_lastScenePoint; BrowserPage *page = m_brwoser->getBrowserPageForPoint(point); @@ -105,6 +113,7 @@ void BrowserMagniFier::updateImage() void BrowserMagniFier::showMagnigierImage(QPoint mousePos, QPoint magnifierPos, double scaleFactor) { + qDebug() << "BrowserMagniFier::showMagnigierImage at" << mousePos << "with scale" << scaleFactor; scaleFactor += 2; m_lastScenePoint = mousePos; @@ -144,6 +153,7 @@ void BrowserMagniFier::showMagnigierImage(QPoint mousePos, QPoint magnifierPos, void BrowserMagniFier::onUpdateMagnifierImage(const MagnifierInfo_t &task, const QImage &image) { + qDebug() << "BrowserMagniFier::onUpdateMagnifierImage"; if (task.mousePos == m_lastPoint && qFuzzyCompare(task.scaleFactor, m_lastScaleFactor)) setMagniFierImage(image); } diff --git a/reader/browser/BrowserMenu.cpp b/reader/browser/BrowserMenu.cpp index 70c74cc7..e32544a7 100644 --- a/reader/browser/BrowserMenu.cpp +++ b/reader/browser/BrowserMenu.cpp @@ -10,14 +10,17 @@ #include "Global.h" #include +#include BrowserMenu::BrowserMenu(QWidget *parent) : DMenu(parent) { + qDebug() << "BrowserMenu created"; DFontSizeManager::instance()->bind(this, DFontSizeManager::T6); } void BrowserMenu::initActions(DocSheet *sheet, int index, SheetMenuType_e type, const QString ©text) { + qDebug() << "BrowserMenu::initActions type:" << type << "index:" << index << "fileType:" << sheet->fileType(); m_type = type; m_pColorWidgetAction = nullptr; if (type == DOC_MENU_ANNO_ICON) { @@ -157,6 +160,7 @@ void BrowserMenu::initActions(DocSheet *sheet, int index, SheetMenuType_e type, void BrowserMenu::hideEvent(QHideEvent *event) { + qDebug() << "BrowserMenu hidden"; emit sigMenuHide(); DMenu::hideEvent(event); @@ -164,6 +168,7 @@ void BrowserMenu::hideEvent(QHideEvent *event) QAction *BrowserMenu::createAction(const QString &displayname, const QString &objectname) { + qDebug() << "BrowserMenu::createAction:" << objectname; QAction *action = new QAction(displayname, this); action->setObjectName(objectname); connect(action, SIGNAL(triggered()), this, SLOT(onItemClicked())); @@ -173,11 +178,14 @@ QAction *BrowserMenu::createAction(const QString &displayname, const QString &ob void BrowserMenu::onItemClicked() { - emit signalMenuItemClicked(sender()->objectName()); + QString actionName = sender()->objectName(); + qInfo() << "BrowserMenu item clicked:" << actionName; + emit signalMenuItemClicked(actionName); } void BrowserMenu::onSetHighLight() { + qDebug() << "BrowserMenu::onSetHighLight type:" << m_type; if (m_type == DOC_MENU_SELECT_TEXT) { emit signalMenuItemClicked("AddTextHighlight"); } else if (m_type == DOC_MENU_ANNO_HIGHLIGHT) { diff --git a/reader/browser/BrowserPage.cpp b/reader/browser/BrowserPage.cpp index 4446adf0..765746eb 100644 --- a/reader/browser/BrowserPage.cpp +++ b/reader/browser/BrowserPage.cpp @@ -25,12 +25,14 @@ #include #include #include +#include const int ICON_SIZE = 23; BrowserPage::BrowserPage(SheetBrowser *parent, int index, DocSheet *sheet) : QGraphicsItem(), m_sheet(sheet), m_parent(parent), m_index(index) { + qDebug() << "BrowserPage created, index:" << index; setAcceptHoverEvents(true); setFlag(QGraphicsItem::ItemIsPanel); @@ -40,6 +42,7 @@ BrowserPage::BrowserPage(SheetBrowser *parent, int index, DocSheet *sheet) : BrowserPage::~BrowserPage() { + qDebug() << "BrowserPage destroyed, index:" << m_index; PageRenderThread::clearImageTasks(m_sheet, this); qDeleteAll(m_annotations); @@ -84,6 +87,7 @@ QRectF BrowserPage::bookmarkMouseRect() void BrowserPage::setBookmark(const bool &hasBookmark) { + qDebug() << "BrowserPage::setBookmark:" << hasBookmark; m_bookmark = hasBookmark; if (hasBookmark) @@ -160,6 +164,7 @@ void BrowserPage::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio void BrowserPage::render(const double &scaleFactor, const Dr::Rotation &rotation, const bool &renderLater, const bool &force) { + qDebug() << "BrowserPage::render scale:" << scaleFactor << "rotation:" << rotation << "force:" << force; if (!force && renderLater && qFuzzyCompare(scaleFactor, m_scaleFactor) && rotation == m_rotation) return; @@ -316,6 +321,7 @@ void BrowserPage::renderViewPort() void BrowserPage::handleRenderFinished(const int &pixmapId, const QPixmap &pixmap, const QRect &slice) { + qDebug() << "BrowserPage::handleRenderFinished pixmapId:" << pixmapId << "slice:" << slice; if (m_pixmapId != pixmapId) return; @@ -394,8 +400,11 @@ void BrowserPage::handleAnnotationLoaded(const QList &annots) QImage BrowserPage::getCurrentImage(int width, int height) { - if (m_pixmap.isNull()) + qDebug() << "Getting current image, requested size:" << width << "x" << height; + if (m_pixmap.isNull()) { + qWarning() << "Pixmap is null, returning empty image"; return QImage(); + } //获取图片比原图还大,就不需要原图了 if (qMin(width, height) > qMax(m_pixmap.width(), m_pixmap.height())) @@ -408,6 +417,7 @@ QImage BrowserPage::getCurrentImage(int width, int height) QImage BrowserPage::getImagePoint(double scaleFactor, QPoint point) { + qDebug() << "Getting image at point:" << point << "with scale factor:" << scaleFactor; QTransform transform; transform.rotate(m_rotation * 90); @@ -462,8 +472,10 @@ void BrowserPage::loadWords() { m_wordNeeded = true; - if (m_wordIsRendering) + if (m_wordIsRendering) { + qDebug() << "Word is rendering, return"; return; + } if (m_wordHasRendered) { //如果已经加载则取消隐藏和改变大小 @@ -498,6 +510,7 @@ void BrowserPage::loadWords() void BrowserPage::clearPixmap() { + qDebug() << "Clearing pixmap for page" << m_index; if (m_renderPixmapScaleFactor < -0.0001) return; @@ -611,6 +624,7 @@ bool BrowserPage::updateAnnotation(deepin_reader::Annotation *annotation, const Annotation *BrowserPage::addHighlightAnnotation(QString text, QColor color) { + qInfo() << "BrowserPage::addHighlightAnnotation text:" << text << "color:" << color; Annotation *highLightAnnot = nullptr; QList boundaries; @@ -869,6 +883,7 @@ QPointF BrowserPage::getTopLeftPos() bool BrowserPage::removeAnnotation(deepin_reader::Annotation *annota) { + qInfo() << "Removing annotation" << annota << "from page" << m_index; if (nullptr == annota) return false; @@ -909,6 +924,7 @@ bool BrowserPage::removeAnnotation(deepin_reader::Annotation *annota) Annotation *BrowserPage::addIconAnnotation(const QRectF &rect, const QString &text) { + qInfo() << "Adding icon annotation at rect:" << rect << "with text:" << text; Annotation *annot = m_sheet->renderer()->addIconAnnotation(itemIndex(), rect, text); if (annot) { @@ -964,6 +980,7 @@ bool BrowserPage::sceneEvent(QEvent *event) void BrowserPage::setSearchHighlightRectf(const QVector §ions) { + qDebug() << "Setting search highlight for" << sections.size() << "sections"; if (sections.size() > 0) { if (m_parent->currentPage() == this->itemIndex() + 1) m_searchSelectLighRectf = sections.first(); @@ -974,6 +991,7 @@ void BrowserPage::setSearchHighlightRectf(const QVector §ions) void BrowserPage::clearSearchHighlightRects() { + qDebug() << "Clearing search highlights"; m_searchSelectLighRectf.clear(); m_searchLightrectLst.clear(); update(); @@ -1080,8 +1098,7 @@ BrowserWord *BrowserPage::getBrowserWord(const QPointF &point) bool BrowserPage::isBigDoc() { - if (Dr::PDF == m_sheet->fileType() && boundingRect().width() > 1000 && boundingRect().height() > 1000) - return true; - - return false; + bool isBig = Dr::PDF == m_sheet->fileType() && boundingRect().width() > 1000 && boundingRect().height() > 1000; + qDebug() << "Checking if document is big:" << isBig; + return isBig; } diff --git a/reader/browser/BrowserWord.cpp b/reader/browser/BrowserWord.cpp index a04c160b..8d066f6a 100644 --- a/reader/browser/BrowserWord.cpp +++ b/reader/browser/BrowserWord.cpp @@ -8,15 +8,18 @@ #include "Model.h" #include +#include #include BrowserWord::BrowserWord(QGraphicsItem *parent, deepin_reader::Word word) : QGraphicsItem(parent), m_word(word) { + qDebug() << "BrowserWord created, text:" << word.text; setZValue(deepin_reader::Z_ORDER_SELECT_TEXT); } void BrowserWord::setScaleFactor(qreal scaleFactor) { + qDebug() << "BrowserWord::setScaleFactor:" << scaleFactor; m_scaleFactor = scaleFactor; update(); } @@ -28,6 +31,7 @@ QString BrowserWord::text() void BrowserWord::setSelectable(bool enable) { + qDebug() << "BrowserWord::setSelectable:" << enable; m_selectable = enable; setFlag(QGraphicsItem::ItemIsSelectable, enable); @@ -46,6 +50,7 @@ QRectF BrowserWord::boundingBox() const void BrowserWord::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) { if (isSelected()) { + qDebug() << "BrowserWord::paint - selected:" << m_word.text; painter->setBrush(QColor(72, 118, 255, 100)); painter->setPen(Qt::NoPen); painter->drawRect(option->rect.x() + 1, option->rect.y() + 1, option->rect.width() - 2, option->rect.height() - 2); diff --git a/reader/browser/PageRenderThread.cpp b/reader/browser/PageRenderThread.cpp index b33c228d..6b9a4e76 100644 --- a/reader/browser/PageRenderThread.cpp +++ b/reader/browser/PageRenderThread.cpp @@ -21,6 +21,7 @@ bool PageRenderThread::s_quitForever = false; PageRenderThread::PageRenderThread(QObject *parent) : QThread(parent) { + qDebug() << "PageRenderThread created"; qRegisterMetaType("deepin_reader::Document *"); qRegisterMetaType>("QList"); qRegisterMetaType>("QList"); @@ -46,6 +47,7 @@ PageRenderThread::PageRenderThread(QObject *parent) : QThread(parent) PageRenderThread::~PageRenderThread() { + qDebug() << "PageRenderThread destroyed"; m_quit = true; wait(); } @@ -126,17 +128,21 @@ void PageRenderThread::appendTask(DocPageNormalImageTask task) PageRenderThread *instance = PageRenderThread::instance(); if (nullptr == instance) { + qWarning() << "PageRenderThread instance is null"; return; } instance->m_pageNormalImageMutex.lock(); instance->m_pageNormalImageTasks.append(task); + qDebug() << "Append normal image task, page:" << task.page->itemIndex(); instance->m_pageNormalImageMutex.unlock(); - if (!instance->isRunning()) + if (!instance->isRunning()) { + qDebug() << "Starting render thread"; instance->start(); + } } void PageRenderThread::appendTask(DocPageSliceImageTask task) @@ -513,33 +519,34 @@ bool PageRenderThread::popNextDocCloseTask(DocCloseTask &task) bool PageRenderThread::execNextDocPageNormalImageTask() { - qDebug() << "正在执行正常取图片任务..."; + qDebug() << "Executing normal image task..."; if (m_quit) { - qDebug() << "正常取图片任务已结束"; + qDebug() << "Render thread quitting, abort task"; return false; } - DocPageNormalImageTask task; if (!popNextDocPageNormalImageTask(task)) { - qDebug() << "任务池不存在正常取图片任务,已结束"; + qDebug() << "No normal image tasks in queue"; return false; } - if (!DocSheet::existSheet(task.sheet)) { - qDebug() << "文档不存在,正常取图片任务已结束"; + qWarning() << "Sheet no longer exists, skip task"; return true; } QImage image = task.sheet->getImage(task.page->itemIndex(), task.rect.width(), task.rect.height()); - if (!image.isNull()) + if (image.isNull()) { + qWarning() << "Failed to get image for page:" << task.page->itemIndex(); + } else { + qDebug() << "Image rendered successfully for page:" << task.page->itemIndex(); emit sigDocPageNormalImageTaskFinished(task, QPixmap::fromImage(image)); + } - qDebug() << "执行取正常取图片任务已完成"; return true; } @@ -801,10 +808,13 @@ void PageRenderThread::destroyForever() PageRenderThread *PageRenderThread::instance() { - if (s_quitForever) + if (s_quitForever) { + qDebug() << "Render thread permanently quit"; return nullptr; + } if (nullptr == s_instance) { + qDebug() << "Creating new render thread instance"; s_instance = new PageRenderThread; } diff --git a/reader/browser/PageSearchThread.cpp b/reader/browser/PageSearchThread.cpp index 2d5970fa..b21556c1 100644 --- a/reader/browser/PageSearchThread.cpp +++ b/reader/browser/PageSearchThread.cpp @@ -15,39 +15,47 @@ QMap PageSearchThread::m_cjktokangximap; PageSearchThread::PageSearchThread(QObject *parent) : QThread(parent) { - + qDebug() << "PageSearchThread created"; } PageSearchThread::~PageSearchThread() { + qDebug() << "PageSearchThread destroyed"; m_quit = true; this->wait(); } void PageSearchThread::startSearch(DocSheet *sheet, QString text) { + qDebug() << "Starting search for:" << text; stopSearch(); m_quit = false; m_startIndex = 0; m_sheet = sheet; m_searchText = text; start(); + qDebug() << "Search thread started"; } void PageSearchThread::stopSearch() { + qDebug() << "Stopping search"; m_quit = true; this->wait(); m_sheet = nullptr; + qDebug() << "Search stopped"; } void PageSearchThread::run() { - if (nullptr == m_sheet) + if (nullptr == m_sheet) { + qWarning() << "Search run failed: sheet is null"; return; + } initCJKtoKangxi(); + qDebug() << "Searching through" << m_sheet->pageCount() << "pages"; bool isSearchResultNotEmpty = false; // 没有搜索结果 int size = m_sheet->pageCount(); QString searchTextKangxi = m_searchText; @@ -58,7 +66,10 @@ void PageSearchThread::run() } for (int index = 0; index < size; index++) { - if (m_quit) return; + if (m_quit) { + qDebug() << "Search cancelled"; + return; + } SearchResult searchres; @@ -73,8 +84,10 @@ void PageSearchThread::run() bool hasWord = searchres.setctionsFillText(getText); // if (hasWord) { + qDebug() << "Found matches on page" << index + 1; if (!isSearchResultNotEmpty) { isSearchResultNotEmpty = true; + qDebug() << "First search result found"; // 只要搜索到结果就emit该信号 emit sigSearchResultNotEmpty(); } @@ -91,7 +104,7 @@ void PageSearchThread::initCJKtoKangxi() QFile file(":/CJK2Kangxi.dict"); if (!file.open(QIODevice::ReadOnly)) { - qInfo() << "open dictFile error :" << file.error(); + qWarning() << "Failed to open CJK dictionary:" << file.errorString(); return; } diff --git a/reader/browser/SheetBrowser.cpp b/reader/browser/SheetBrowser.cpp index 79e9aac6..4184eb10 100644 --- a/reader/browser/SheetBrowser.cpp +++ b/reader/browser/SheetBrowser.cpp @@ -48,9 +48,11 @@ DWIDGET_USE_NAMESPACE const qreal deltaManhattanLength = 12.0; SheetBrowser::SheetBrowser(DocSheet *parent) : DGraphicsView(parent), m_sheet(parent) { + qDebug() << "SheetBrowser constructor started"; setMouseTracking(true); setScene(new QGraphicsScene(this)); + qDebug() << "Graphics scene created"; setFrameShape(QFrame::NoFrame); @@ -62,27 +64,26 @@ SheetBrowser::SheetBrowser(DocSheet *parent) : DGraphicsView(parent), m_sheet(pa setAttribute(Qt::WA_AcceptTouchEvents); - grabGesture(Qt::PinchGesture);//捏合缩放 + grabGesture(Qt::PinchGesture); + qDebug() << "Pinch gesture enabled"; setProperty("pinchgetsturing", false); m_scroller = QScroller::scroller(this); + qDebug() << "Scroller initialized"; connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onVerticalScrollBarValueChanged(int))); - connect(verticalScrollBar(), &QScrollBar::sliderPressed, this, &SheetBrowser::onRemoveDocSlideGesture); - connect(verticalScrollBar(), &QScrollBar::sliderReleased, this, &SheetBrowser::onSetDocSlideGesture); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onHorizontalScrollBarValueChanged(int))); - connect(horizontalScrollBar(), &QScrollBar::sliderPressed, this, &SheetBrowser::onRemoveDocSlideGesture); - connect(horizontalScrollBar(), &QScrollBar::sliderReleased, this, &SheetBrowser::onSetDocSlideGesture); m_tipsWidget = new TipsWidget(this); m_tipsWidget->setAccessibleName("Tips"); m_tipsWidget->setAutoChecked(true); + qDebug() << "Tips widget created"; connect(this, SIGNAL(sigAddHighLightAnnot(BrowserPage *, QString, QColor)), this, SLOT(onAddHighLightAnnot(BrowserPage *, QString, QColor)), Qt::QueuedConnection); @@ -92,16 +93,24 @@ SheetBrowser::SheetBrowser(DocSheet *parent) : DGraphicsView(parent), m_sheet(pa this->horizontalScrollBar()->setProperty("_d_slider_spaceLeft", 8); this->horizontalScrollBar()->setProperty("_d_slider_spaceRight", 8); this->horizontalScrollBar()->setAccessibleName("horizontalScrollBar"); + + qDebug() << "SheetBrowser constructor completed"; } SheetBrowser::~SheetBrowser() { + qDebug() << "SheetBrowser destructor started"; disconnect(this, SIGNAL(sigAddHighLightAnnot(BrowserPage *, QString, QColor)), this, SLOT(onAddHighLightAnnot(BrowserPage *, QString, QColor))); qDeleteAll(m_items); + qDebug() << "Deleted all browser items, count:" << m_items.count(); - if (nullptr != m_noteEditWidget) + if (nullptr != m_noteEditWidget) { delete m_noteEditWidget; + qDebug() << "Note edit widget deleted"; + } + + qDebug() << "SheetBrowser destructor completed"; } QImage SheetBrowser::firstThumbnail(const QString &filePath) @@ -139,46 +148,62 @@ QImage SheetBrowser::firstThumbnail(const QString &filePath) void SheetBrowser::init(SheetOperation &operation, const QSet &bookmarks) { + qDebug() << "Initializing SheetBrowser with page count:" << m_sheet->pageCount() + << "and" << bookmarks.count() << "bookmarks"; + int pageCount = m_sheet->pageCount(); for (int i = 0; i < pageCount; ++i) { BrowserPage *item = new BrowserPage(this, i, m_sheet); + qDebug() << "Created BrowserPage for page:" << i; - if (bookmarks.contains(i)) + if (bookmarks.contains(i)) { item->setBookmark(true); + qDebug() << "Set bookmark for page:" << i; + } m_items.append(item); - if (m_sheet->renderer()->getPageSize(i).width() > m_maxWidth) - m_maxWidth = m_sheet->renderer()->getPageSize(i).width(); + QSizeF pageSize = m_sheet->renderer()->getPageSize(i); + if (pageSize.width() > m_maxWidth) + m_maxWidth = pageSize.width(); - if (m_sheet->renderer()->getPageSize(i).height() > m_maxHeight) - m_maxHeight = m_sheet->renderer()->getPageSize(i).height(); + if (pageSize.height() > m_maxHeight) + m_maxHeight = pageSize.height(); scene()->addItem(item); } + qDebug() << "Max page dimensions - width:" << m_maxWidth << "height:" << m_maxHeight; + setMouseShape(operation.mouseShape); + qDebug() << "Mouse shape set to:" << operation.mouseShape; deform(operation); m_initPage = operation.currentPage; - m_hasLoaded = true; + + qInfo() << "SheetBrowser initialized successfully, initial page:" << m_initPage; } void SheetBrowser::setMouseShape(const Dr::MouseShape &shape) { + qDebug() << "Setting mouse shape to:" << shape; closeMagnifier(); + if (Dr::MouseShapeHand == shape) { setDragMode(QGraphicsView::ScrollHandDrag); foreach (BrowserPage *item, m_items) item->setWordSelectable(false); + qDebug() << "Set to hand drag mode, word selection disabled"; } else if (Dr::MouseShapeNormal == shape) { setDragMode(QGraphicsView::NoDrag); foreach (BrowserPage *item, m_items) item->setWordSelectable(true); + qDebug() << "Set to normal mode, word selection enabled"; } + m_bHandAndLink = false; } @@ -261,12 +286,18 @@ void SheetBrowser::onAddHighLightAnnot(BrowserPage *page, QString text, QColor c void SheetBrowser::showNoteEditWidget(deepin_reader::Annotation *annotation, const QPoint &point) { // 超链接与高亮区域重合时,手形工具下只响应超链接 - if (annotation == nullptr || m_bHandAndLink) + if (annotation == nullptr || m_bHandAndLink) { + qDebug() << "Skipping note edit - annotation null or hand and link mode"; return; + } + qDebug() << "Showing note edit widget for annotation at:" << point; + m_tipsWidget->hide(); if (m_noteEditWidget == nullptr) { m_noteEditWidget = new TextEditShadowWidget(this); + qDebug() << "Created new TextEditShadowWidget"; + connect(m_noteEditWidget->getTextEditWidget(), &TextEditWidget::sigNeedShowTips, m_sheet, &DocSheet::showTips); connect(m_noteEditWidget->getTextEditWidget(), &TextEditWidget::sigRemoveAnnotation, this, &SheetBrowser::onRemoveAnnotation); connect(m_noteEditWidget->getTextEditWidget(), &TextEditWidget::sigUpdateAnnotation, this, &SheetBrowser::onUpdateAnnotation); @@ -278,6 +309,8 @@ void SheetBrowser::showNoteEditWidget(deepin_reader::Annotation *annotation, con m_noteEditWidget->getTextEditWidget()->setEditText(annotation->contents()); m_noteEditWidget->getTextEditWidget()->setAnnotation(annotation); m_noteEditWidget->showWidget(point); + + qDebug() << "Note edit widget shown with content:" << annotation->contents(); } bool SheetBrowser::calcIconAnnotRect(BrowserPage *page, const QPointF &point, QRectF &iconRect) @@ -698,8 +731,12 @@ bool SheetBrowser::event(QEvent *event) bool SheetBrowser::gestureEvent(QGestureEvent *event) { - if (QGesture *pinch = event->gesture(Qt::PinchGesture)) + qDebug() << "Gesture event received, type:" << event->gestures().count(); + + if (QGesture *pinch = event->gesture(Qt::PinchGesture)) { + qDebug() << "Processing pinch gesture"; pinchTriggered(reinterpret_cast(pinch)); + } return true; } @@ -752,6 +789,9 @@ void SheetBrowser::pinchTriggered(QPinchGesture *gesture) void SheetBrowser::deform(SheetOperation &operation) { + qDebug() << "Deforming view with scale factor:" << operation.scaleFactor + << "mode:" << operation.scaleMode << "rotation:" << operation.rotation; + m_lastScaleFactor = operation.scaleFactor; //根据缩放模式调整缩放比例 @@ -926,9 +966,12 @@ void SheetBrowser::resizeEvent(QResizeEvent *event) void SheetBrowser::mousePressEvent(QMouseEvent *event) { + qDebug() << "Mouse press at:" << event->pos() << "button:" << event->button(); + QPointF point = event->pos(); BrowserPage *page = getBrowserPageForPoint(point); + qDebug() << "Event on page:" << (page ? page->itemIndex() : -1); m_scroller->stop(); @@ -937,7 +980,6 @@ void SheetBrowser::mousePressEvent(QMouseEvent *event) m_iconAnnot = nullptr; if (btn == Qt::LeftButton) { - //清除上一次选中 clearSelectIconAnnotAfterMenu(); @@ -947,20 +989,24 @@ void SheetBrowser::mousePressEvent(QMouseEvent *event) m_canTouchScreen = true; m_repeatTimer.start(REPEAT_MOVE_DELAY, this); m_scroller->handleInput(QScroller::InputPress, event->pos(), static_cast(event->timestamp())); + qDebug() << "Touch screen gesture started"; } else { m_selectStartWord = nullptr; m_selectEndWord = nullptr; scene()->setSelectionArea(QPainterPath()); + qDebug() << "Selection area cleared"; } m_selectWord = nullptr; m_selectEndPos = QPointF(); m_selectStartPos = m_selectPressedPos = mapToScene(event->pos()); + qDebug() << "Selection start position:" << m_selectPressedPos; if (page != nullptr) { m_selectIndex = page->itemIndex(); //add by dxh 2020-8-19 防止书签附近有文字时,操作书签无效 page->setPageBookMark(page->mapFromScene(m_selectPressedPos)); + qDebug() << "Set page bookmark at:" << page->mapFromScene(m_selectPressedPos); } deepin_reader::Annotation *clickAnno = getClickAnnot(page, m_selectPressedPos, true); @@ -975,6 +1021,7 @@ void SheetBrowser::mousePressEvent(QMouseEvent *event) m_iconAnnotationMovePos = m_selectPressedPos; m_annotationInserting = false; m_iconAnnot = clickAnno; + qDebug() << "Text annotation selected:" << clickAnno->contents(); return DGraphicsView::mousePressEvent(event); } } else if (btn == Qt::RightButton) { @@ -1459,8 +1506,12 @@ int SheetBrowser::currentScrollValueForPage() void SheetBrowser::setCurrentPage(int page) { - if (page < 1 || page > allPages()) + if (page < 1 || page > allPages()) { + qWarning() << "Invalid page number:" << page << "max pages:" << allPages(); return; + } + + qDebug() << "Setting current page to:" << page; m_bNeedNotifyCurPageChanged = false; @@ -1481,6 +1532,7 @@ void SheetBrowser::setCurrentPage(int page) m_bNeedNotifyCurPageChanged = true; curpageChanged(page); + qDebug() << "Page changed to:" << page << "successfully"; } bool SheetBrowser::getExistImage(int index, QImage &image, int width, int height) @@ -1610,19 +1662,25 @@ void SheetBrowser::showEvent(QShowEvent *event) void SheetBrowser::handlePrepareSearch() { + qDebug() << "Preparing search for file type:" << m_sheet->fileType(); + //目前只有PDF开放搜索功能 - if (m_sheet->fileType() != Dr::FileType::PDF && m_sheet->fileType() != Dr::FileType::DOCX) + if (m_sheet->fileType() != Dr::FileType::PDF && m_sheet->fileType() != Dr::FileType::DOCX) { + qDebug() << "Search not supported for current file type"; return; + } if (m_findWidget == nullptr) { m_findWidget = new FindWidget(this->window()); int windowY = this->mapTo(this->window(), QPoint(0, 0)).y(); m_findWidget->setYOff(windowY); m_findWidget->setDocSheet(m_sheet); + qDebug() << "Created new FindWidget with Y offset:" << windowY; } m_findWidget->updatePosition(); m_findWidget->setSearchEditFocus(); + qDebug() << "FindWidget positioned and focused"; #ifdef DTKWIDGET_CLASS_DSizeMode connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { if(m_findWidget && m_findWidget->isVisible()){ @@ -1767,8 +1825,13 @@ void SheetBrowser::handleSearchResultComming(const deepin_reader::SearchResult & void SheetBrowser::handleFindFinished(int searchcnt) { - if (m_findWidget) - m_findWidget->setEditAlert(searchcnt == 0); + qInfo() << "Search finished with" << searchcnt << "results"; + + if (m_findWidget) { + bool alert = searchcnt == 0; + m_findWidget->setEditAlert(alert); + qDebug() << "FindWidget alert set to:" << alert; + } } void SheetBrowser::curpageChanged(int curpage) @@ -1783,13 +1846,17 @@ bool SheetBrowser::isLink(QPointF viewpoint) { BrowserPage *page = getBrowserPageForPoint(viewpoint); - if (nullptr == page) + if (nullptr == page) { + qDebug() << "No page found at viewpoint"; return false; + } viewpoint = translate2Local(viewpoint); - //判断当前位置是否有link - return m_sheet->renderer()->inLink(page->itemIndex(), viewpoint); + bool isLink = m_sheet->renderer()->inLink(page->itemIndex(), viewpoint); + qDebug() << "Link check at page" << page->itemIndex() << "position" << viewpoint << "result:" << isLink; + + return isLink; } Link SheetBrowser::getLinkAtPoint(QPointF viewpoint) diff --git a/reader/document/DjVuModel.cpp b/reader/document/DjVuModel.cpp index b37ff500..cdc98ede 100644 --- a/reader/document/DjVuModel.cpp +++ b/reader/document/DjVuModel.cpp @@ -416,10 +416,12 @@ DjVuPage::DjVuPage(const DjVuDocument *parent, int index, const ddjvu_pageinfo_t m_size(pageinfo.width, pageinfo.height), m_resolution(pageinfo.dpi) { + qDebug() << "DjVuPage constructor called for page" << index << "with size" << m_size << "and DPI" << m_resolution; } DjVuPage::~DjVuPage() { + qDebug() << "DjVuPage destructor called for page" << m_index; } QSizeF DjVuPage::sizeF() const @@ -429,11 +431,13 @@ QSizeF DjVuPage::sizeF() const QImage DjVuPage::render(int width, int height, const QRect &slice)const { + qDebug() << "Rendering page" << m_index << "with size" << width << "x" << height << "and slice" << slice; LOCK_PAGE ddjvu_page_t *page = ddjvu_page_create_by_pageno(m_parent->m_document, m_index); if (page == nullptr) { + qWarning() << "Failed to create page for rendering, page is null"; return QImage(); } @@ -450,6 +454,7 @@ QImage DjVuPage::render(int width, int height, const QRect &slice)const } if (status >= DDJVU_JOB_FAILED) { + qWarning() << "Page decoding failed with status:" << status; ddjvu_page_release(page); return QImage(); @@ -481,6 +486,7 @@ QImage DjVuPage::render(int width, int height, const QRect &slice)const QImage image(static_cast(renderrect.w), static_cast(renderrect.h), QImage::Format_RGB32); if (!ddjvu_page_render(page, DDJVU_RENDER_COLOR, &pagerect, &renderrect, m_parent->m_format, static_cast(image.bytesPerLine()), reinterpret_cast< char * >(image.bits()))) { + qWarning() << "Failed to render page" << m_index; image = QImage(); } @@ -493,10 +499,11 @@ QImage DjVuPage::render(int width, int height, const QRect &slice)const deepin_reader::DjVuDocument *DjVuDocument::loadDocument(const QString &filePath, deepin_reader::Document::Error &error) { + qInfo() << "Starting to load DjVu document from path:" << filePath; ddjvu_context_t *context = ddjvu_context_create("deepin_reader"); if (context == nullptr) { - + qCritical() << "Failed to create DjVu context"; error = Document::FileError; return nullptr; } @@ -508,6 +515,7 @@ deepin_reader::DjVuDocument *DjVuDocument::loadDocument(const QString &filePath, #endif // DDJVUAPI_VERSION if (document == nullptr) { + qCritical() << "Failed to create DjVu document from file:" << filePath; ddjvu_context_release(context); error = Document::FileError; @@ -517,6 +525,7 @@ deepin_reader::DjVuDocument *DjVuDocument::loadDocument(const QString &filePath, waitForMessageTag(context, DDJVU_DOCINFO); if (ddjvu_document_decoding_error(document)) { + qCritical() << "Document decoding error occurred"; ddjvu_document_release(document); ddjvu_context_release(context); @@ -529,6 +538,7 @@ deepin_reader::DjVuDocument *DjVuDocument::loadDocument(const QString &filePath, djvuDocument->m_filePath = filePath; error = Document::NoError; + qInfo() << "Successfully loaded DjVu document from:" << filePath << "with" << djvuDocument->pageCount() << "pages"; return djvuDocument; } @@ -661,6 +671,7 @@ DjVuDocument::DjVuDocument(ddjvu_context_t *context, ddjvu_document_t *document) DjVuDocument::~DjVuDocument() { + qDebug() << "DjVuDocument destructor called, releasing resources for document:" << m_filePath; ddjvu_document_release(m_document); ddjvu_context_release(m_context); ddjvu_format_release(m_format); @@ -668,6 +679,7 @@ DjVuDocument::~DjVuDocument() int DjVuDocument::pageCount() const { + qDebug() << "Getting page count for document:" << m_filePath; LOCK_DOCUMENT return ddjvu_document_get_pagenum(m_document); @@ -691,6 +703,7 @@ Page *DjVuDocument::page(int index) const } if (status >= DDJVU_JOB_FAILED) { + qWarning() << "Failed to get page info, status:" << status; return nullptr; } @@ -708,6 +721,7 @@ QStringList DjVuDocument::saveFilter() const bool DjVuDocument::saveAs(const QString &filePath) const { + qInfo() << "Starting to save document to:" << filePath << "from original path:" << m_filePath; LOCK_DOCUMENT #ifdef _MSC_VER @@ -721,6 +735,7 @@ bool DjVuDocument::saveAs(const QString &filePath) const #endif // _MSC_VER if (file == nullptr) { + qWarning() << "Failed to open file for saving:" << filePath; return false; } @@ -732,7 +747,12 @@ bool DjVuDocument::saveAs(const QString &filePath) const fclose(file); - return !ddjvu_job_error(job); + bool success = !ddjvu_job_error(job); + if (!success) { + qWarning() << "Failed to save document to:" << filePath << "Error:" << ddjvu_job_status(job); + } + qInfo() << "Document save operation" << (success ? "succeeded" : "failed"); + return success; } bool DjVuDocument::save() const @@ -759,11 +779,15 @@ bool DjVuDocument::save() const file.remove(); //不remove会出现第二次导出丢失数据问题 (保存动作完成之后,如果当前文档是当初打开那个,下一次导出会出错) - if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) + if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { + qWarning() << "Failed to open file for writing:" << m_filePath; return false; + } - if (array.size() != file.write(array)) + if (array.size() != file.write(array)) { + qWarning() << "Failed to write all data to file"; result = false; + } file.flush();//函数将用户缓存中的内容写入内核缓冲区 fsync(file.handle());//将内核缓冲写入文件(磁盘) @@ -809,6 +833,7 @@ bool DjVuDocument::save() const Properties DjVuDocument::properties() const { + qDebug() << "Getting document properties for:" << m_filePath; Properties properties; LOCK_DOCUMENT @@ -842,6 +867,8 @@ Properties DjVuDocument::properties() const void DjVuDocument::prepareFileInfo() { + qDebug() << "Preparing file info for document:" << m_filePath; + for (int index = 0, count = ddjvu_document_get_filenum(m_document); index < count; ++index) { ddjvu_fileinfo_t fileinfo; diff --git a/reader/document/Model.cpp b/reader/document/Model.cpp index f7cfaa8b..c9fe8cb6 100755 --- a/reader/document/Model.cpp +++ b/reader/document/Model.cpp @@ -23,18 +23,21 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & QProcess **pprocess, deepin_reader::Document::Error &error) { + qDebug() << "Creating document handler for type:" << fileType << "file:" << filePath; + deepin_reader::Document *document = nullptr; - qDebug() << "需要转换的文档: " << filePath; + qDebug() << "Processing document file:" << filePath; if (Dr::PDF == fileType) { - qDebug() << "当前文档类型为: PDF"; + qDebug() << "Handling PDF document"; document = deepin_reader::PDFDocument::loadDocument(filePath, password, error); } else if (Dr::DJVU == fileType) { - qDebug() << "当前文档类型为: DJVU"; + qDebug() << "Handling DJVU document"; document = deepin_reader::DjVuDocument::loadDocument(filePath, error); } else if (Dr::DOCX == fileType) { - qDebug() << "当前文档类型为: DOCX"; + qDebug() << "Starting DOCX document conversion process"; if (nullptr == pprocess) { + qCritical() << "Invalid process pointer for DOCX conversion"; error = deepin_reader::Document::ConvertFailed; return nullptr; } @@ -58,7 +61,7 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & QFile file(filePath); if (!file.copy(targetDoc)) { - qInfo() << QString("copy %1 failed.").arg(filePath); + qCritical() << "Failed to copy file from" << filePath << "to" << targetDoc; error = deepin_reader::Document::ConvertFailed; return nullptr; } @@ -67,7 +70,7 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & QProcess decompressor; *pprocess = &decompressor; decompressor.setWorkingDirectory(convertedFileDir); - qDebug() << "正在解压文档..." << targetDoc; + qInfo() << "Unzipping DOCX document:" << targetDoc; QString unzipCommand = "unzip " + targetDoc; qDebug() << "执行命令: " << unzipCommand; #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) @@ -76,26 +79,26 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & decompressor.startCommand(unzipCommand); #endif if (!decompressor.waitForStarted()) { - qInfo() << "start unzip failed"; + qCritical() << "Failed to start unzip process for file:" << targetDoc; error = deepin_reader::Document::ConvertFailed; *pprocess = nullptr; return nullptr; } if (!decompressor.waitForFinished()) { - qInfo() << "unzip failed"; + qCritical() << "Unzip process failed for file:" << targetDoc; error = deepin_reader::Document::ConvertFailed; *pprocess = nullptr; return nullptr; } if (!QDir(convertedFileDir + "/word").exists()) { - qInfo() << "unzip failed! " << (convertedFileDir + "/word") << "is not exists!"; + qCritical() << "Unzip failed! Directory not found:" << (convertedFileDir + "/word"); error = deepin_reader::Document::ConvertFailed; if (!(QProcess::CrashExit == decompressor.exitStatus() && 9 == decompressor.exitCode())) { *pprocess = nullptr; } return nullptr; } - qDebug() << "文档解压完成"; + qInfo() << "Document unzipped successfully"; QTemporaryFile tmpFile(convertedFileDir + "/word/" + QCoreApplication::applicationName() + "_XXXXXX.html"); if( tmpFile.open()) { //fix 232871 tmpHtmlFilePath = tmpFile.fileName(); // returns the unique file name @@ -104,7 +107,7 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & QProcess converter; *pprocess = &converter; converter.setWorkingDirectory(convertedFileDir + "/word"); - qDebug() << "正在将docx文档转换成html..." << tmpHtmlFilePath; + qInfo() << "Converting DOCX to HTML:" << tmpHtmlFilePath; // QFile targetDocFile(targetDoc); // if (targetDocFile.exists()) { // qDebug() << "文档" << targetDocFile.fileName() << "存在!"; @@ -121,20 +124,20 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & converter.startCommand(pandocCommand); #endif if (!converter.waitForStarted()) { - qInfo() << "start pandoc failed"; + qCritical() << "Failed to start pandoc conversion process"; error = deepin_reader::Document::ConvertFailed; *pprocess = nullptr; return nullptr; } if (!converter.waitForFinished()) { - qInfo() << "pandoc failed"; + qCritical() << "Pandoc conversion process failed"; error = deepin_reader::Document::ConvertFailed; *pprocess = nullptr; return nullptr; } QFile tmpHtmlFile(tmpHtmlFilePath); if (!tmpHtmlFile.exists()) { - qInfo() << "pandoc failed! " << tmpHtmlFilePath << " doesn't exist"; + qCritical() << "Pandoc conversion failed! Output file not found:" << tmpHtmlFilePath; error = deepin_reader::Document::ConvertFailed; // 转换过程中关闭应用,docsheet被释放,对应的*pprocess已不存在 if (!(QProcess::CrashExit == converter.exitStatus() && 9 == converter.exitCode())) { @@ -142,13 +145,13 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & } return nullptr; } - qDebug() << "docx转html完成"; + qInfo() << "DOCX to HTML conversion completed"; // html -> pdf QProcess converter2; *pprocess = &converter2; converter2.setWorkingDirectory(convertedFileDir + "/word"); - qDebug() << "正在将html转换成pdf..." << realFilePath; + qInfo() << "Converting HTML to PDF:" << realFilePath; QString htmltopdfCommand = prefix + "/lib/deepin-reader/htmltopdf " + tmpHtmlFilePath + " " + realFilePath; qDebug() << "执行命令: " << htmltopdfCommand; @@ -158,13 +161,13 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & converter2.startCommand(htmltopdfCommand); #endif if (!converter2.waitForStarted()) { - qInfo() << "start htmltopdf failed"; + qCritical() << "Failed to start htmltopdf conversion process"; error = deepin_reader::Document::ConvertFailed; *pprocess = nullptr; return nullptr; } if (!converter2.waitForFinished()) { - qInfo() << "htmltopdf failed"; + qCritical() << "Htmltopdf conversion process failed"; error = deepin_reader::Document::ConvertFailed; *pprocess = nullptr; return nullptr; @@ -172,24 +175,32 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & QFile realFile(realFilePath); if (!realFile.exists()) { - qInfo() << "htmltopdf failed! " << realFilePath << " doesn't exist"; + qCritical() << "Htmltopdf conversion failed! Output file not found:" << realFilePath; error = deepin_reader::Document::ConvertFailed; if (!(QProcess::CrashExit == converter.exitStatus() && 9 == converter.exitCode())) { *pprocess = nullptr; } return nullptr; } - qDebug() << "html转pdf完成"; + qInfo() << "HTML to PDF conversion completed"; *pprocess = nullptr; + qInfo() << "Loading converted PDF document:" << realFilePath; document = deepin_reader::PDFDocument::loadDocument(realFilePath, password, error); } + if (document) { + qInfo() << "Document created successfully for:" << filePath; + } else { + qWarning() << "Failed to create document for:" << filePath << "Error:" << error; + } return document; } bool SearchResult::setctionsFillText(std::function getText) { + qDebug() << "Filling search result text for page:" << page; + bool ret = false; for (auto §ion : sections) { for (auto &line : section) { @@ -202,11 +213,14 @@ bool SearchResult::setctionsFillText(std::function getText } } } + qDebug() << "Search result text filled, success:" << ret; return ret; } QRectF SearchResult::sectionBoundingRect(const PageSection §ion) { + qDebug() << "Calculating bounding rect for search result section"; + QRectF ret; for (const PageLine &line : section) { ret = ret.united(line.rect); diff --git a/reader/document/PDFModel.cpp b/reader/document/PDFModel.cpp index c6ad192b..6ba5d4ea 100644 --- a/reader/document/PDFModel.cpp +++ b/reader/document/PDFModel.cpp @@ -20,11 +20,13 @@ namespace deepin_reader { PDFAnnotation::PDFAnnotation(DPdfAnnot *dannotation) : Annotation(), m_dannotation(dannotation) { - + qDebug() << "Creating PDF annotation with type:" << (dannotation ? dannotation->type() : -1); } PDFAnnotation::~PDFAnnotation() { + qDebug() << "Destroying PDF annotation"; + m_dannotation = nullptr; } @@ -43,16 +45,20 @@ QList PDFAnnotation::boundary() const QString PDFAnnotation::contents() const { - if (nullptr == m_dannotation) + if (nullptr == m_dannotation) { + qWarning() << "Attempt to get contents from null annotation"; return QString(); + } return m_dannotation->text(); } int PDFAnnotation::type() { - if (nullptr == m_dannotation) + if (nullptr == m_dannotation) { + qWarning() << "Attempt to get type from null annotation"; return -1; + } return m_dannotation->type(); } @@ -65,12 +71,12 @@ DPdfAnnot *PDFAnnotation::ownAnnotation() PDFPage::PDFPage(QMutex *mutex, DPdfPage *page) : m_docMutex(mutex), m_page(page) { - + qInfo() << "Creating PDF page handler"; } PDFPage::~PDFPage() { - + qInfo() << "Destroying PDF page handler"; } QSizeF PDFPage::sizeF() const @@ -80,6 +86,8 @@ QSizeF PDFPage::sizeF() const QImage PDFPage::render(int width, int height, const QRect &slice) const { + qInfo() << "Rendering PDF page with size:" << width << "x" << height << "slice:" << slice; + LOCK_DOCUMENT QRect ratioRect = slice.isValid() ? QRect(slice.x(), slice.y(), slice.width(), slice.height()) : QRect(); @@ -118,6 +126,7 @@ Link PDFPage::getLinkAtPoint(const QPointF &pos) bool PDFPage::hasWidgetAnnots() const { + qDebug() << "Checking if page has widget annotations"; return m_page->widgets().count() > 0; } @@ -128,6 +137,8 @@ QString PDFPage::text(const QRectF &rect) const QList PDFPage::words() { + qInfo() << "Extracting text words from PDF page"; + LOCK_DOCUMENT if (m_wordLoaded) @@ -272,6 +283,8 @@ QList PDFPage::words() QVector PDFPage::search(const QString &text, bool matchCase, bool wholeWords) const { + qInfo() << "Searching PDF page for text:" << text << "matchCase:" << matchCase << "wholeWords:" << wholeWords; + LOCK_DOCUMENT return m_page->search(text, matchCase, wholeWords); @@ -279,6 +292,8 @@ QVector PDFPage::search(const QString &text, bool matchCase, bool w QList< Annotation * > PDFPage::annotations() const { + qDebug() << "Retrieving PDF page annotations"; + QList< Annotation * > annotations; const QList &annos = m_page->annots(); @@ -292,15 +307,21 @@ QList< Annotation * > PDFPage::annotations() const Annotation *PDFPage::addHighlightAnnotation(const QList &boundaries, const QString &text, const QColor &color) { + qInfo() << "Adding highlight annotation with boundaries:" << boundaries << "text:" << text << "color:" << color; + return new PDFAnnotation(m_page->createHightLightAnnot(boundaries, text, color)); } bool PDFPage::removeAnnotation(Annotation *annotation) { + qInfo() << "Removing PDF annotation"; + PDFAnnotation *PDFAnnotation = static_cast< class PDFAnnotation * >(annotation); - if (PDFAnnotation == nullptr) + if (PDFAnnotation == nullptr) { + qWarning() << "Attempt to remove null annotation"; return false; + } m_page->removeAnnot(PDFAnnotation->m_dannotation); @@ -313,8 +334,12 @@ bool PDFPage::removeAnnotation(Annotation *annotation) bool PDFPage::updateAnnotation(Annotation *annotation, const QString &text, const QColor &color) { - if (nullptr == annotation) + qInfo() << "Updating PDF annotation with text:" << text << "color:" << color; + + if (nullptr == annotation) { + qWarning() << "Attempt to update null annotation"; return false; + } if (m_page->annots().contains(annotation->ownAnnotation())) { if (annotation->type() == DPdfAnnot::AText) @@ -329,16 +354,24 @@ bool PDFPage::updateAnnotation(Annotation *annotation, const QString &text, cons Annotation *PDFPage::addIconAnnotation(const QRectF &rect, const QString &text) { - if (nullptr == m_page) + qInfo() << "Adding icon annotation at rect:" << rect << "with text:" << text; + + if (nullptr == m_page) { + qCritical() << "Attempt to add icon annotation to null page"; return nullptr; + } return new PDFAnnotation(m_page->createTextAnnot(rect.center(), text)); } Annotation *PDFPage::moveIconAnnotation(Annotation *annot, const QRectF &rect) { - if (nullptr == m_page || nullptr == annot) + qInfo() << "Moving icon annotation to rect:" << rect; + + if (nullptr == m_page || nullptr == annot) { + qCritical() << "Attempt to move icon annotation with null page or annotation"; return nullptr; + } if (annot->ownAnnotation()) { m_page->updateTextAnnot(annot->ownAnnotation(), annot->ownAnnotation()->text(), rect.center()); @@ -351,6 +384,8 @@ Annotation *PDFPage::moveIconAnnotation(Annotation *annot, const QRectF &rect) PDFDocument::PDFDocument(DPdfDoc *document) : m_document(document) { + qInfo() << "Creating PDF document handler with page count:" << (document ? document->pageCount() : 0); + m_docMutex = new QMutex; QScreen *srn = QApplication::screens().value(0); @@ -362,8 +397,10 @@ PDFDocument::PDFDocument(DPdfDoc *document) : PDFDocument::~PDFDocument() { + qInfo() << "Destroying PDF document handler"; + //需要确保pages先被析构完成 - qDebug() << "正在释放当前 document ..."; + qDebug() << "Releasing PDF document resources..."; m_docMutex->lock(); @@ -374,20 +411,27 @@ PDFDocument::~PDFDocument() m_docMutex->unlock(); delete m_docMutex; - qDebug() << "当前 document 已释放"; + qDebug() << "PDF document resources released"; } int PDFDocument::pageCount() const { + qDebug() << "Retrieving PDF document page count"; + return m_document->pageCount(); } Page *PDFDocument::page(int index) const { + qInfo() << "Retrieving PDF page at index:" << index; + if (DPdfPage *page = m_document->page(index, m_xRes, m_yRes)) { - if (page->isValid()) + if (page->isValid()) { + qDebug() << "PDF page at index" << index << "is valid"; return new PDFPage(m_docMutex, page); + } + qWarning() << "PDF page at index" << index << "is invalid"; } return nullptr; @@ -395,21 +439,29 @@ Page *PDFDocument::page(int index) const QString PDFDocument::label(int index) const { + qDebug() << "Retrieving label for PDF page at index:" << index; + return m_document->label(index); } QStringList PDFDocument::saveFilter() const { + qDebug() << "Retrieving PDF save filters"; + return QStringList() << "Portable document format (*.pdf)"; } bool PDFDocument::save() const { + qInfo() << "Saving PDF document"; + return m_document->save(); } bool PDFDocument::saveAs(const QString &filePath) const { + qInfo() << "Saving PDF document as:" << filePath; + return m_document->saveAs(filePath); } @@ -429,8 +481,12 @@ void collectOuleLine(const DPdfDoc::Outline &cOutline, Outline &outline) Outline PDFDocument::outline() const { - if (m_outline.size() > 0) + qInfo() << "Retrieving PDF document outline"; + + if (m_outline.size() > 0) { + qDebug() << "Returning cached PDF outline"; return m_outline; + } const DPdfDoc::Outline &cOutline = m_document->outline(m_xRes, m_yRes); @@ -441,8 +497,12 @@ Outline PDFDocument::outline() const Properties PDFDocument::properties() const { - if (m_fileProperties.size() > 0) + qInfo() << "Retrieving PDF document properties"; + + if (m_fileProperties.size() > 0) { + qDebug() << "Returning cached PDF properties"; return m_fileProperties; + } m_fileProperties = m_document->proeries(); @@ -451,18 +511,26 @@ Properties PDFDocument::properties() const PDFDocument *PDFDocument::loadDocument(const QString &filePath, const QString &password, deepin_reader::Document::Error &error) { + qInfo() << "Loading PDF document from:" << filePath << "with password:" << (!password.isEmpty() ? "[provided]" : "[not provided]"); + DPdfDoc *document = new DPdfDoc(filePath, password); if (document->status() == DPdfDoc::SUCCESS) { + qInfo() << "PDF document loaded successfully"; error = Document::NoError; return new PDFDocument(document); } else if (document->status() == DPdfDoc::PASSWORD_ERROR) { - if (password.isEmpty()) + if (password.isEmpty()) { + qWarning() << "PDF document requires password but none provided"; error = Document::NeedPassword; - else + } else { + qWarning() << "Incorrect password provided for PDF document"; error = Document::WrongPassword; - } else + } + } else { + qCritical() << "Failed to load PDF document, error code:" << document->status(); error = Document::FileError; + } delete document; diff --git a/reader/load_libs.c b/reader/load_libs.c index 7a3f3cfd..a00239c1 100755 --- a/reader/load_libs.c +++ b/reader/load_libs.c @@ -36,26 +36,35 @@ static LoadLibNames g_ldnames; static LoadLibs *pLibs = NULL; static LoadLibs *newClass(void) { + fprintf(stderr, "INFO: Allocating LoadLibs structure\n"); pLibs = (LoadLibs *)malloc(sizeof(LoadLibs)); + if (!pLibs) { + fprintf(stderr, "ERROR: Failed to allocate LoadLibs\n"); + return NULL; + } pLibs->m_document_clip_copy = NULL; pLibs->m_document_close = NULL; // RTLD_NOW:在dlopen返回前,解析出全部没有定义的符号,解析不出来返回NULL。 // RTLD_LAZY:暂缓决定,等有需要时再解出符号 void *handle = NULL; if (g_ldnames.chDocumentPr != NULL) { + fprintf(stderr, "INFO: Loading library: %s\n", g_ldnames.chDocumentPr); handle = dlopen(g_ldnames.chDocumentPr, RTLD_LAZY); if (handle == NULL) { + fprintf(stderr, "ERROR: Failed to load library\n"); PrintError(); } } else { - fprintf(stderr, "Error: Library path is NULL\n"); + fprintf(stderr, "ERROR: Library path is NULL\n"); } if (handle == NULL) { return pLibs; } + fprintf(stderr, "INFO: Resolving symbol: document_clip_copy\n"); pLibs->m_document_clip_copy = (uos_document_clip_copy)dlsym(handle, "document_clip_copy"); PrintError(); + fprintf(stderr, "INFO: Resolving symbol: document_close\n"); pLibs->m_document_close = (uos_document_close)dlsym(handle, "document_close"); PrintError(); @@ -69,16 +78,25 @@ static LoadLibs *newClass(void) * 注意:方法内部要加锁,防止多线程多次创建 * */ LoadLibs *getLoadLibsInstance() -{ +{ static pthread_mutex_t mutex; + static int mutex_initialized = 0; + + if (!mutex_initialized) { + pthread_mutex_init(&mutex, NULL); + mutex_initialized = 1; + fprintf(stderr, "INFO: Initialized mutex for thread safety\n"); + } + //双检锁 if (pLibs == NULL) { - // 这里要对pLibs加锁 + fprintf(stderr, "INFO: Acquiring mutex for LoadLibs initialization\n"); pthread_mutex_lock(&mutex); - if (pLibs == NULL) + if (pLibs == NULL) { + fprintf(stderr, "INFO: Creating new LoadLibs instance\n"); pLibs = newClass(); - - //退出时解锁 + } + fprintf(stderr, "INFO: Releasing mutex after LoadLibs initialization\n"); pthread_mutex_unlock(&mutex); } @@ -87,10 +105,17 @@ LoadLibs *getLoadLibsInstance() void setLibNames(LoadLibNames tmp) { + fprintf(stderr, "INFO: Setting library names\n"); if(tmp.chDocumentPr == NULL) { + fprintf(stderr, "WARNING: Received NULL document printer library path\n"); g_ldnames.chDocumentPr = NULL; } else { - g_ldnames.chDocumentPr = ( char*)malloc(strlen(tmp.chDocumentPr)+1); + fprintf(stderr, "INFO: Copying library path: %s\n", tmp.chDocumentPr); + g_ldnames.chDocumentPr = (char*)malloc(strlen(tmp.chDocumentPr)+1); + if (!g_ldnames.chDocumentPr) { + fprintf(stderr, "ERROR: Failed to allocate memory for library path\n"); + return; + } strcpy(g_ldnames.chDocumentPr,tmp.chDocumentPr); } } diff --git a/reader/main.cpp b/reader/main.cpp index 70edae33..234d9e39 100755 --- a/reader/main.cpp +++ b/reader/main.cpp @@ -26,7 +26,8 @@ DWIDGET_USE_NAMESPACE int main(int argc, char *argv[]) { PERF_PRINT_BEGIN("POINT-01", ""); - qDebug() << __FUNCTION__ << "启动应用!"; + qDebug() << "Application starting with arguments:" << argc; + qDebug() << "Command line:" << QCoreApplication::arguments().join(" "); // 依赖DTK的程序,如果要在root下或者非deepin/uos环境下运行不会发生异常,就需要加上该环境变量 if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) { @@ -34,6 +35,7 @@ int main(int argc, char *argv[]) } // Init DTK. + qDebug() << "Initializing DTK application"; Application a(argc, argv); QCommandLineParser parser; parser.addHelpOption(); @@ -58,11 +60,17 @@ int main(int argc, char *argv[]) if (parser.isSet("thumbnail") && parser.isSet("filePath") && parser.isSet("thumbnailPath")) { QString filePath = parser.value("filePath"); QString thumbnailPath = parser.value("thumbnailPath"); - if (filePath.isEmpty() || thumbnailPath.isEmpty()) + qDebug() << "Generating thumbnail for:" << filePath; + qDebug() << "Thumbnail output path:" << thumbnailPath; + if (filePath.isEmpty() || thumbnailPath.isEmpty()) { + qWarning() << "Empty file path or thumbnail path"; return -1; + } - if (!CentralDocPage::firstThumbnail(filePath, thumbnailPath)) + if (!CentralDocPage::firstThumbnail(filePath, thumbnailPath)) { + qWarning() << "Failed to generate thumbnail"; return -1; + } return 0; } @@ -73,8 +81,11 @@ int main(int argc, char *argv[]) PERF_PRINT_BEGIN("POINT-05", ""); //=======通知已经打开的进程 - if (!DBusObject::instance()->registerOrNotify(arguments)) + qDebug() << "Registering DBus service"; + if (!DBusObject::instance()->registerOrNotify(arguments)) { + qInfo() << "Another instance is running, exiting"; return 0; + } QAccessible::installFactory(accessibleFactory); @@ -84,11 +95,15 @@ int main(int argc, char *argv[]) Q_UNUSED(savetheme) #endif + qDebug() << "Setting up log appenders"; Dtk::Core::DLogManager::registerConsoleAppender(); Dtk::Core::DLogManager::registerFileAppender(); - if (!MainWindow::allowCreateWindow()) + qDebug() << "Checking if new window can be created"; + if (!MainWindow::allowCreateWindow()) { + qWarning() << "Maximum window count reached"; return -1; + } qDebug() << __FUNCTION__ << "正在创建主窗口..."; qApp->setAttribute(Qt::AA_ForceRasterWidgets, true); @@ -101,9 +116,11 @@ int main(int argc, char *argv[]) PERF_PRINT_END("POINT-01", ""); + qDebug() << "Entering main event loop"; int result = a.exec(); PERF_PRINT_END("POINT-02", ""); + qInfo() << "Application exiting with code:" << result; return result; } diff --git a/reader/sidebar/BookMarkDelegate.cpp b/reader/sidebar/BookMarkDelegate.cpp index 2a7ebfd6..4913ab12 100644 --- a/reader/sidebar/BookMarkDelegate.cpp +++ b/reader/sidebar/BookMarkDelegate.cpp @@ -17,12 +17,17 @@ BookMarkDelegate::BookMarkDelegate(QAbstractItemView *parent) : DStyledItemDelegate(parent) { + qInfo() << "Creating BookMarkDelegate with parent widget:" << parent; + m_parent = parent; } void BookMarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + qDebug() << "Painting bookmark item at row:" << index.row(); + if (index.isValid()) { + qDebug() << "Index is valid, proceeding with bookmark item rendering"; const QPixmap &pixmap = index.data(ImageinfoType_e::IMAGE_PIXMAP).value(); QSize pageSize = index.data(ImageinfoType_e::IMAGE_PAGE_SIZE).toSize(); @@ -32,6 +37,7 @@ void BookMarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti const QRect &rect = QRect(option.rect.x() + 10, option.rect.center().y() - scalePixSize.height() / 2, scalePixSize.width(), scalePixSize.height()); if (!pixmap.isNull()) { + qDebug() << "Rendering bookmark thumbnail image"; const QPixmap &scalePix = pixmap.scaled(pageSize); //clipPath pixmap painter->save(); @@ -46,7 +52,9 @@ void BookMarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti painter->save(); painter->setBrush(Qt::NoBrush); painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); - if (m_parent->selectionModel()->isRowSelected(index.row(), index.parent())) { + bool isSelected = m_parent->selectionModel()->isRowSelected(index.row(), index.parent()); + qDebug() << "Drawing selection border - selected:" << isSelected; + if (isSelected) { painter->setPen(QPen(DTK_NAMESPACE::Gui::DGuiApplicationHelper::instance()->applicationPalette().highlight().color(), 2)); painter->drawRoundedRect(rect, borderRadius, borderRadius); } else { @@ -64,6 +72,7 @@ void BookMarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti font = DFontSizeManager::instance()->t8(font); painter->setFont(font); const QString &pageText = index.data(ImageinfoType_e::IMAGE_INDEX_TEXT).toString(); + qDebug() << "Rendering page number text:" << pageText; int pagetextHeight = painter->fontMetrics().height(); painter->drawText(rect.right() + 18, option.rect.y() + margin, option.rect.width(), pagetextHeight, Qt::AlignVCenter | Qt::AlignLeft, pageText); painter->restore(); diff --git a/reader/sidebar/BookMarkWidget.cpp b/reader/sidebar/BookMarkWidget.cpp index 4924f306..d006e8d3 100644 --- a/reader/sidebar/BookMarkWidget.cpp +++ b/reader/sidebar/BookMarkWidget.cpp @@ -24,13 +24,15 @@ const int LEFTMINHEIGHT = 80; BookMarkWidget::BookMarkWidget(DocSheet *sheet, DWidget *parent) : BaseWidget(parent), m_sheet(sheet) { + qDebug() << "Creating BookMarkWidget for document:" << (sheet ? sheet->filePath() : "null"); + initWidget(); onUpdateTheme(); } BookMarkWidget::~BookMarkWidget() { - + qDebug() << "Destroying BookMarkWidget"; } void BookMarkWidget::initWidget() @@ -73,8 +75,12 @@ void BookMarkWidget::initWidget() void BookMarkWidget::prevPage() { - if (m_sheet.isNull()) + qDebug() << "Navigating to previous bookmark, current row:" << m_pImageListView->currentIndex().row(); + + if (m_sheet.isNull()) { + qWarning() << "Cannot navigate - sheet is null"; return; + } int curPage = m_pImageListView->currentIndex().row() - 1; if (curPage < 0) @@ -85,8 +91,12 @@ void BookMarkWidget::prevPage() void BookMarkWidget::pageUp() { - if (m_sheet.isNull()) + qDebug() << "Performing page up navigation"; + + if (m_sheet.isNull()) { + qWarning() << "Cannot page up - sheet is null"; return; + } const QModelIndex &pageIndex = m_pImageListView->pageUpIndex(); if (!pageIndex.isValid()) @@ -97,8 +107,12 @@ void BookMarkWidget::pageUp() void BookMarkWidget::nextPage() { - if (m_sheet.isNull()) + qDebug() << "Navigating to next bookmark, current row:" << m_pImageListView->currentIndex().row(); + + if (m_sheet.isNull()) { + qWarning() << "Cannot navigate - sheet is null"; return; + } int curPage = m_pImageListView->currentIndex().row() + 1; m_sheet->jumpToIndex(m_pImageListView->getPageIndexForModelIndex(curPage)); @@ -106,8 +120,12 @@ void BookMarkWidget::nextPage() void BookMarkWidget::pageDown() { - if (m_sheet.isNull()) + qDebug() << "Performing page down navigation"; + + if (m_sheet.isNull()) { + qWarning() << "Cannot page down - sheet is null"; return; + } const QModelIndex &pageIndex = m_pImageListView->pageDownIndex(); if (!pageIndex.isValid()) @@ -118,8 +136,12 @@ void BookMarkWidget::pageDown() void BookMarkWidget::handleOpenSuccess() { - if (bIshandOpenSuccess) + qDebug() << "Handling document open success, bookmark count:" << m_sheet->getBookMarkList().size(); + + if (bIshandOpenSuccess) { + qDebug() << "Open success already handled, skipping"; return; + } bIshandOpenSuccess = true; const QSet &pageList = m_sheet->getBookMarkList(); if (pageList.contains(m_sheet->currentIndex())) @@ -131,10 +153,13 @@ void BookMarkWidget::handlePage(int index) { bool result = m_pImageListView->scrollToIndex(index); m_pAddBookMarkBtn->setDisabled(result); + qDebug() << "Handling page change to index:" << index << "scroll result:" << result; } void BookMarkWidget::handleBookMark(int index, int state) { + qDebug() << "Updating bookmark state - index:" << index << "state:" << (state ? "added" : "removed"); + if (state) { int nCurIndex = m_sheet->currentIndex(); if (nCurIndex == index) m_pAddBookMarkBtn->setEnabled(false); @@ -149,13 +174,21 @@ void BookMarkWidget::handleBookMark(int index, int state) void BookMarkWidget::deleteItemByKey() { + qDebug() << "Deleting bookmark by key"; + int curIndex = m_pImageListView->getPageIndexForModelIndex(m_pImageListView->currentIndex().row()); - if (curIndex >= 0) + if (curIndex >= 0) { + qDebug() << "Removing bookmark at index:" << curIndex; m_sheet->setBookMark(curIndex, false); + } else { + qWarning() << "Invalid index for bookmark deletion"; + } } void BookMarkWidget::deleteAllItem() { + qDebug() << "Preparing to delete all bookmarks"; + QList bookmarks; int itemsize = m_pImageListView->model()->rowCount(); for (int i = 0; i < itemsize; i++) { @@ -169,13 +202,19 @@ void BookMarkWidget::deleteAllItem() void BookMarkWidget::onAddBookMarkClicked() { - if (m_sheet.isNull()) return; + qDebug() << "Add bookmark button clicked"; + if (m_sheet.isNull()) { + qWarning() << "Cannot add bookmark - sheet is null"; + return; + } int nPage = m_sheet->currentIndex(); m_sheet->setBookMark(nPage, true); } void BookMarkWidget::adaptWindowSize(const double &scale) { + qDebug() << "Adapting window size with scale factor:" << scale; + m_pImageListView->setProperty("adaptScale", scale); m_pImageListView->setItemSize(QSize(static_cast(LEFTMINWIDTH * scale), LEFTMINHEIGHT)); m_pImageListView->reset(); @@ -184,6 +223,8 @@ void BookMarkWidget::adaptWindowSize(const double &scale) void BookMarkWidget::showMenu() { + qDebug() << "Showing bookmark context menu, item count:" << (m_pImageListView ? m_pImageListView->count() : 0); + if (m_pImageListView && m_pImageListView->count()) { m_pImageListView->showMenu(); } @@ -191,6 +232,8 @@ void BookMarkWidget::showMenu() void BookMarkWidget::onUpdateTheme() { + qDebug() << "Updating widget theme colors"; + QPalette plt = QApplication::palette(); plt.setColor(QPalette::Window, plt.color(QPalette::Base)); setPalette(plt); @@ -200,11 +243,15 @@ void BookMarkWidget::onUpdateTheme() void BookMarkWidget::onListMenuClick(const int &iType) { + qDebug() << "Bookmark list menu action triggered, type:" << iType << + (iType == E_BOOKMARK_DELETE ? "(Delete)" : "(Delete All)"); + if (iType == E_BOOKMARK_DELETE) { deleteItemByKey(); } else if (iType == E_BOOKMARK_DELETE_ALL) { int result = SaveDialog::showTipDialog(tr("Are you sure you want to delete all bookmarks?") ,this); if (result == 1) { + qDebug() << "User confirmed deletion of all bookmarks"; deleteAllItem(); } } diff --git a/reader/sidebar/CatalogTreeView.cpp b/reader/sidebar/CatalogTreeView.cpp index c1956e9a..126acce5 100644 --- a/reader/sidebar/CatalogTreeView.cpp +++ b/reader/sidebar/CatalogTreeView.cpp @@ -86,6 +86,8 @@ QVariant CatalogModel::data(const QModelIndex &index, int role) const CatalogTreeView::CatalogTreeView(DocSheet *sheet, DWidget *parent) : DTreeView(parent), m_sheet(sheet) { + qDebug() << "Creating CatalogTreeView for document:" << (sheet ? sheet->filePath() : "null"); + ActiveProxyStyle *style = new ActiveProxyStyle(this); setStyle(style); setFrameShape(QFrame::NoFrame); @@ -117,7 +119,7 @@ CatalogTreeView::CatalogTreeView(DocSheet *sheet, DWidget *parent) CatalogTreeView::~CatalogTreeView() { - + qDebug() << "Destroying CatalogTreeView"; } void CatalogTreeView::setRightControl(bool hasControl) @@ -127,6 +129,8 @@ void CatalogTreeView::setRightControl(bool hasControl) void CatalogTreeView::parseCatalogData(const deepin_reader::Section &ol, QStandardItem *parentItem) { + qDebug() << "Parsing catalog section:" << ol.title << "with" << ol.children.size() << "children"; + foreach (auto s, ol.children) { // 2级显示 if (s.nIndex >= 0) { auto itemList = getItemList(s.title, s.nIndex, s.offsetPointF.x(), s.offsetPointF.y()); @@ -161,12 +165,16 @@ QList CatalogTreeView::getItemList(const QString &title, const void CatalogTreeView::handleOpenSuccess() { + qDebug() << "Handling document open success, building catalog tree"; + auto model = reinterpret_cast(this->model()); if (model) { model->clear(); - if (nullptr == m_sheet) + if (nullptr == m_sheet) { + qCritical() << "Cannot build catalog tree - document sheet is null"; return; + } m_index = m_sheet->currentIndex(); const deepin_reader::Outline &ol = m_sheet->outline(); @@ -184,20 +192,28 @@ void CatalogTreeView::handleOpenSuccess() void CatalogTreeView::slotCollapsed(const QModelIndex &index) { + qDebug() << "Catalog tree item collapsed:" << index.data().toString(); + Q_UNUSED(index); - if (nullptr == m_sheet) + if (nullptr == m_sheet) { + qWarning() << "Cannot handle collapse event - document sheet is null"; return; + } setIndex(m_index, m_title); } void CatalogTreeView::slotExpanded(const QModelIndex &index) { + qDebug() << "Catalog tree item expanded:" << index.data().toString(); + Q_UNUSED(index); - if (nullptr == m_sheet) + if (nullptr == m_sheet) { + qWarning() << "Cannot handle expand event - document sheet is null"; return; + } setIndex(m_index, m_title); } @@ -207,8 +223,10 @@ void CatalogTreeView::currentChanged(const QModelIndex ¤t, const QModelInd Q_UNUSED(previous); if (!rightnotifypagechanged) { - if (nullptr == m_sheet) + if (nullptr == m_sheet) { + qCritical() << "Cannot navigate - document sheet is null"; return; + } int nIndex = current.data(Qt::UserRole + 1).toInt(); double left = current.data(Qt::UserRole + 2).toDouble(); @@ -224,8 +242,12 @@ void CatalogTreeView::currentChanged(const QModelIndex ¤t, const QModelInd void CatalogTreeView::onItemClicked(const QModelIndex ¤t) { - if (nullptr == m_sheet) + qDebug() << "Catalog item clicked:" << current.data().toString() << "page:" << current.data(Qt::UserRole + 1).toInt(); + + if (nullptr == m_sheet) { + qCritical() << "Cannot navigate to clicked item - document sheet is null"; return; + } int nIndex = current.data(Qt::UserRole + 1).toInt(); double left = current.data(Qt::UserRole + 2).toDouble(); @@ -256,6 +278,8 @@ void CatalogTreeView::keyPressEvent(QKeyEvent *event) void CatalogTreeView::setIndex(int index, const QString &title) { + qDebug() << "Setting catalog selection - page:" << index << "title:" << (title.isEmpty() ? "[any]" : title); + m_index = index; m_title = title; this->clearSelection(); @@ -298,30 +322,40 @@ void CatalogTreeView::resizeCoulumnWidth() void CatalogTreeView::nextPage() { + qDebug() << "Navigating to next catalog item"; + const QModelIndex &newCurrent = this->moveCursor(QAbstractItemView::MoveDown, Qt::NoModifier); scrollToIndex(newCurrent); } void CatalogTreeView::pageDownPage() { + qDebug() << "Page down navigation in catalog"; + const QModelIndex &newCurrent = this->moveCursor(QAbstractItemView::MovePageDown, Qt::NoModifier); scrollToIndex(newCurrent); } void CatalogTreeView::prevPage() { + qDebug() << "Navigating to previous catalog item"; + const QModelIndex &newCurrent = this->moveCursor(QAbstractItemView::MoveUp, Qt::NoModifier); scrollToIndex(newCurrent); } void CatalogTreeView::pageUpPage() { + qDebug() << "Page up navigation in catalog"; + const QModelIndex &newCurrent = this->moveCursor(QAbstractItemView::MovePageUp, Qt::NoModifier); scrollToIndex(newCurrent); } void CatalogTreeView::scrollToIndex(const QModelIndex &newIndex) { + qDebug() << "Scrolling to catalog index:" << newIndex.data().toString(); + if (newIndex.isValid()) { rightnotifypagechanged = false; currentChanged(newIndex, currentIndex()); @@ -332,6 +366,8 @@ void CatalogTreeView::scrollToIndex(const QModelIndex &newIndex) void CatalogTreeView::onFontChanged(const QFont &font) { + qDebug() << "Handling font change in catalog view"; + Q_UNUSED(font); resizeCoulumnWidth(); } diff --git a/reader/sidebar/CatalogWidget.cpp b/reader/sidebar/CatalogWidget.cpp index 37d07ef0..ae1ab632 100644 --- a/reader/sidebar/CatalogWidget.cpp +++ b/reader/sidebar/CatalogWidget.cpp @@ -14,16 +14,20 @@ CatalogWidget::CatalogWidget(DocSheet *sheet, DWidget *parent) : BaseWidget(parent), m_sheet(sheet) { + qDebug() << "Creating CatalogWidget for document:" << (sheet ? sheet->filePath() : "null"); + initWidget(); } CatalogWidget::~CatalogWidget() { - + qDebug() << "Destroying CatalogWidget"; } void CatalogWidget::initWidget() { + qDebug() << "Initializing CatalogWidget UI components"; + QHBoxLayout *titleLayout = new QHBoxLayout; titleLayout->setSpacing(0); @@ -55,6 +59,8 @@ void CatalogWidget::initWidget() void CatalogWidget::resizeEvent(QResizeEvent *event) { + qDebug() << "Handling CatalogWidget resize event"; + if (m_strTheme != "" && titleLabel) { setTitleTheme(); } @@ -64,6 +70,8 @@ void CatalogWidget::resizeEvent(QResizeEvent *event) void CatalogWidget::setTitleTheme() { + qDebug() << "Updating catalog title theme:" << m_strTheme << "with width:" << this->width(); + QFont font = DFontSizeManager::instance()->get(DFontSizeManager::T8); QFontMetrics fm(font); @@ -76,8 +84,16 @@ void CatalogWidget::setTitleTheme() void CatalogWidget::handleOpenSuccess() { - if (nullptr == m_sheet || bIshandOpenSuccess) + qDebug() << "Handling document open success, loading catalog"; + + if (nullptr == m_sheet) { + qCritical() << "Cannot load catalog - document sheet is null"; + return; + } + if (bIshandOpenSuccess) { + qDebug() << "Catalog already loaded, skipping"; return; + } bIshandOpenSuccess = true; deepin_reader::FileInfo fileInfo; @@ -91,26 +107,36 @@ void CatalogWidget::handleOpenSuccess() void CatalogWidget::handlePage(int index) { + qDebug() << "Handling page navigation to index:" << index; + m_pTree->setIndex(index); m_pTree->setRightControl(true); } void CatalogWidget::nextPage() { + qDebug() << "Navigating to next catalog item"; + m_pTree->nextPage(); } void CatalogWidget::prevPage() { + qDebug() << "Navigating to previous catalog item"; + m_pTree->prevPage(); } void CatalogWidget::pageDown() { + qDebug() << "Performing page down navigation in catalog"; + m_pTree->pageDownPage(); } void CatalogWidget::pageUp() { + qDebug() << "Performing page up navigation in catalog"; + m_pTree->pageUpPage(); } diff --git a/reader/sidebar/NotesWidget.cpp b/reader/sidebar/NotesWidget.cpp index e829e87c..6b4a7cf5 100644 --- a/reader/sidebar/NotesWidget.cpp +++ b/reader/sidebar/NotesWidget.cpp @@ -14,24 +14,27 @@ #include #include +#include #include const int LEFTMINHEIGHT = 80; - NotesWidget::NotesWidget(DocSheet *sheet, DWidget *parent) : BaseWidget(parent), m_sheet(sheet) { + qDebug() << "NotesWidget created for document:" << (sheet ? sheet->filePath() : "null"); initWidget(); } NotesWidget::~NotesWidget() { - + qDebug() << "NotesWidget destroyed"; } + void NotesWidget::initWidget() { + qDebug() << "Initializing NotesWidget UI"; QVBoxLayout *pVLayout = new QVBoxLayout; pVLayout->setContentsMargins(0, 10, 0, 0); pVLayout->setSpacing(0); @@ -136,14 +139,18 @@ void NotesWidget::deleteAllItem() void NotesWidget::addNoteItem(deepin_reader::Annotation *anno) { - if (anno == nullptr || anno->contents().isEmpty()) + if (anno == nullptr || anno->contents().isEmpty()) { + qWarning() << "Attempt to add invalid annotation"; return; + } ImagePageInfo_t tImagePageInfo; tImagePageInfo.pageIndex = anno->page - 1; tImagePageInfo.strcontents = anno->contents(); tImagePageInfo.annotation = anno; m_pImageListView->getImageModel()->insertPageIndex(tImagePageInfo); + qDebug() << "Added note item for page:" << tImagePageInfo.pageIndex + << "content:" << tImagePageInfo.strcontents.left(20) + "..."; int modelIndex = m_pImageListView->getImageModel()->findItemForAnno(anno); if (modelIndex >= 0) @@ -152,6 +159,11 @@ void NotesWidget::addNoteItem(deepin_reader::Annotation *anno) void NotesWidget::deleteNoteItem(deepin_reader::Annotation *anno) { + if (!anno) { + qWarning() << "Attempt to delete null annotation"; + return; + } + qDebug() << "Deleting note item for page:" << anno->page - 1; m_pImageListView->getImageModel()->removeItemForAnno(anno); } @@ -166,6 +178,7 @@ void NotesWidget::handleOpenSuccess() void NotesWidget::onListMenuClick(const int &iAction) { + qDebug() << "List menu action triggered:" << iAction; if (iAction == E_NOTE_COPY) { copyNoteContent(); } else if (iAction == E_NOTE_DELETE) { @@ -179,6 +192,7 @@ void NotesWidget::onListMenuClick(const int &iAction) void NotesWidget::onListItemClicked(int row) { + qDebug() << "List item clicked at row:" << row; ImagePageInfo_t tImagePageInfo; m_pImageListView->getImageModel()->getModelIndexImageInfo(row, tImagePageInfo); if (tImagePageInfo.pageIndex >= 0) { @@ -188,11 +202,13 @@ void NotesWidget::onListItemClicked(int row) void NotesWidget::onAddAnnotation() { + qDebug() << "Add annotation button clicked"; m_sheet->setAnnotationInserting(true); } void NotesWidget::handleAnntationMsg(const int &msgType, deepin_reader::Annotation *anno) { + qDebug() << "Handling annotation message type:" << msgType; if (msgType == MSG_NOTE_ADD) { addNoteItem(anno); } else if (msgType == MSG_NOTE_DELETE) { diff --git a/reader/sidebar/ReaderImageThreadPoolManager.cpp b/reader/sidebar/ReaderImageThreadPoolManager.cpp index c249e75e..2b22786d 100644 --- a/reader/sidebar/ReaderImageThreadPoolManager.cpp +++ b/reader/sidebar/ReaderImageThreadPoolManager.cpp @@ -6,6 +6,7 @@ #include "ReaderImageThreadPoolManager.h" #include "DocSheet.h" #include "Application.h" +#include #include @@ -49,6 +50,7 @@ void ReadImageTask::run() Q_GLOBAL_STATIC(ReaderImageThreadPoolManager, theInstance) ReaderImageThreadPoolManager::ReaderImageThreadPoolManager() { + qDebug() << "Initializing ReaderImageThreadPoolManager with max threads:" << maxThreadCnt; setMaxThreadCount(maxThreadCnt); } @@ -61,6 +63,7 @@ void ReaderImageThreadPoolManager::addgetDocImageTask(const ReaderImageParam_t & { //To avoid repetitive tasks if (m_taskList.contains(readImageParam)) { + qDebug() << "Skip duplicate task for page:" << readImageParam.pageIndex; return; } @@ -76,6 +79,7 @@ void ReaderImageThreadPoolManager::addgetDocImageTask(const ReaderImageParam_t & //remove invalid task QMutexLocker mutext(&m_runMutex); if (!readImageParam.bForceUpdate && m_taskList.size() >= maxTaskList) { + qDebug() << "Task queue full (" << m_taskList.size() << "), removing excess tasks"; for (int index = maxTaskList; index < m_taskList.size(); index++) { QRunnable *runable = m_taskList.at(index).task; if (this->tryTake(runable)) { @@ -93,6 +97,8 @@ void ReaderImageThreadPoolManager::addgetDocImageTask(const ReaderImageParam_t & task->setThreadPoolManager(this); task->addgetDocImageTask(tParam); m_taskList << tParam; + qDebug() << "Starting new image load task for page:" << tParam.pageIndex + << "total tasks:" << m_taskList.size(); this->start(task); } @@ -100,7 +106,10 @@ void ReaderImageThreadPoolManager::onTaskFinished(const ReaderImageParam_t &task { QMutexLocker mutext(&m_runMutex); - QPixmap pixmap = QPixmap::fromImage(image); + QPixmap pixmap = QPixmap::fromImage(image); + qDebug() << "Task finished for page:" << task.pageIndex + << "image size:" << image.size() + << "remaining tasks:" << m_taskList.size() - 1; setImageForDocSheet(task.sheet, task.pageIndex, pixmap); @@ -113,8 +122,11 @@ void ReaderImageThreadPoolManager::onTaskFinished(const ReaderImageParam_t &task QPixmap ReaderImageThreadPoolManager::getImageForDocSheet(DocSheet *sheet, int pageIndex) { if (m_docSheetImgMap.contains(sheet)) { + qDebug() << "Image cache" << (m_docSheetImgMap[sheet][pageIndex].isNull() ? "miss" : "hit") + << "for page:" << pageIndex; return m_docSheetImgMap[sheet][pageIndex]; } + qDebug() << "No cache found for document"; return QPixmap(); } @@ -126,14 +138,17 @@ void ReaderImageThreadPoolManager::setImageForDocSheet(DocSheet *sheet, int page void ReaderImageThreadPoolManager::onDocProxyDestroyed(QObject *obj) { + qDebug() << "Cleaning up resources for destroyed document proxy"; m_docProxylst.removeAll(obj); m_docSheetImgMap.remove(obj); } void ReaderImageThreadPoolManager::onReceiverDestroyed(QObject *obj) { + qDebug() << "Cleaning up tasks for destroyed receiver"; for (const ReaderImageParam_t &iter : m_taskList) { if (iter.receiver == obj) { + qDebug() << "Removing task for page:" << iter.pageIndex; m_taskList.removeAll(iter); return; } diff --git a/reader/sidebar/SearchResDelegate.cpp b/reader/sidebar/SearchResDelegate.cpp index c111bdb0..9563146e 100644 --- a/reader/sidebar/SearchResDelegate.cpp +++ b/reader/sidebar/SearchResDelegate.cpp @@ -9,21 +9,25 @@ #include "Application.h" #include +#include #include #include #include #include - SearchResDelegate::SearchResDelegate(QAbstractItemView *parent) : DStyledItemDelegate(parent) { m_parent = parent; + qDebug() << "SearchResDelegate created with parent:" << parent; } + void SearchResDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + qDebug() << "Entering SearchResDelegate::paint() for row:" << index.row(); if (index.isValid()) { + qDebug() << "Painting valid index for row:" << index.row(); const QPixmap &pixmap = index.data(ImageinfoType_e::IMAGE_PIXMAP).value(); QSize pageSize = index.data(ImageinfoType_e::IMAGE_PAGE_SIZE).toSize(); @@ -105,11 +109,17 @@ void SearchResDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt painter->setPen(QPen(DTK_NAMESPACE::Gui::DGuiApplicationHelper::instance()->applicationPalette().frameBorder().color(), bottomlineHeight)); painter->drawLine(textStartX, option.rect.bottom() - bottomlineHeight, option.rect.right(), option.rect.bottom() - bottomlineHeight); painter->restore(); + } else { + qWarning() << "Invalid index in SearchResDelegate::paint()"; } + qDebug() << "Exiting SearchResDelegate::paint() for row:" << index.row(); } QSize SearchResDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - return DStyledItemDelegate::sizeHint(option, index); + qDebug() << "Entering SearchResDelegate::sizeHint()"; + QSize size = DStyledItemDelegate::sizeHint(option, index); + qDebug() << "Exiting SearchResDelegate::sizeHint(), returning size:" << size; + return size; } diff --git a/reader/sidebar/SearchResWidget.cpp b/reader/sidebar/SearchResWidget.cpp index 102c6ccb..2367f3d3 100644 --- a/reader/sidebar/SearchResWidget.cpp +++ b/reader/sidebar/SearchResWidget.cpp @@ -11,26 +11,28 @@ #include "Model.h" #include +#include #include const int SEARCH_INDEX = 0; const int TIPS_INDEX = 1; const int LEFTMINHEIGHT = 80; - SearchResWidget::SearchResWidget(DocSheet *sheet, DWidget *parent) : BaseWidget(parent), m_sheet(sheet) { + qDebug() << "SearchResWidget created for document:" << (sheet ? sheet->filePath() : "null"); initWidget(); } SearchResWidget::~SearchResWidget() { - + qDebug() << "SearchResWidget destroyed"; } void SearchResWidget::initWidget() { + qDebug() << "Initializing SearchResWidget UI"; m_stackLayout = new QStackedLayout; m_stackLayout->setContentsMargins(0, 8, 0, 0); m_stackLayout->setSpacing(0); @@ -54,6 +56,7 @@ void SearchResWidget::initWidget() void SearchResWidget::handleSearchResultComming(const deepin_reader::SearchResult &search) { + qDebug() << "Processing search result for page:" << search.page; QString strText; for (const auto §ion : search.sections) { for (const auto &line : section) { @@ -67,10 +70,14 @@ void SearchResWidget::handleSearchResultComming(const deepin_reader::SearchResul int SearchResWidget::handleFindFinished() { int searchCount = m_pImageListView->model()->rowCount(); - if (searchCount <= 0) + qDebug() << "Search finished, found" << searchCount << "results"; + if (searchCount <= 0) { + qDebug() << "Showing no results tip"; m_stackLayout->setCurrentIndex(TIPS_INDEX); - else + } else { + qDebug() << "Showing search results"; m_stackLayout->setCurrentIndex(SEARCH_INDEX); + } return searchCount; } @@ -83,6 +90,7 @@ void SearchResWidget::clearFindResult() void SearchResWidget::searchKey(const QString &searchKey) { + qDebug() << "Setting search key:" << searchKey; m_searchKey = searchKey; } @@ -103,6 +111,7 @@ void SearchResWidget::addSearchsItem(const int &pageIndex, const QString &text, void SearchResWidget::adaptWindowSize(const double &scale) { + qDebug() << "Adapting window size with scale:" << scale; const QModelIndex &curModelIndex = m_pImageListView->currentIndex(); m_pImageListView->setProperty("adaptScale", scale); m_pImageListView->setItemSize(QSize(static_cast(LEFTMINWIDTH * scale), LEFTMINHEIGHT)); diff --git a/reader/sidebar/SheetSidebar.cpp b/reader/sidebar/SheetSidebar.cpp index 8176e356..d83fb444 100644 --- a/reader/sidebar/SheetSidebar.cpp +++ b/reader/sidebar/SheetSidebar.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -28,17 +29,19 @@ SheetSidebar::SheetSidebar(DocSheet *parent, PreviewWidgesFlags widgesFlag) , m_sheet(parent) , m_widgetsFlag(widgesFlag | PREVIEW_SEARCH) { + qDebug() << "SheetSidebar created with flags:" << widgesFlag; initWidget(); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &SheetSidebar::onUpdateWidgetTheme); } SheetSidebar::~SheetSidebar() { - + qDebug() << "SheetSidebar destroyed"; } void SheetSidebar::initWidget() { + qDebug() << "Initializing SheetSidebar UI"; m_scale = 1.0; m_bOldVisible = false; m_bOpenDocOpenSuccess = false; @@ -189,8 +192,10 @@ void SheetSidebar::initWidget() void SheetSidebar::onBtnClicked(int index) { - if (!m_btnGroupMap.contains(index)) + if (!m_btnGroupMap.contains(index)) { + qWarning() << "Invalid button index:" << index; return; + } for (auto iter = m_btnGroupMap.begin(); iter != m_btnGroupMap.end(); iter++) { iter.value()->setChecked(false); @@ -252,6 +257,7 @@ void SheetSidebar::onHandWidgetDocOpenSuccess() void SheetSidebar::handleSearchStart(const QString &text) { + qDebug() << "Starting search for:" << text; for (auto iter = m_btnGroupMap.begin(); iter != m_btnGroupMap.end(); iter++) { iter.value()->setEnabled(false); } @@ -260,6 +266,7 @@ void SheetSidebar::handleSearchStart(const QString &text) m_searchWidget->searchKey(text); onBtnClicked(m_searchId); this->setVisible(true); + qDebug() << "Search UI activated"; } void SheetSidebar::handleSearchStop() @@ -323,9 +330,13 @@ void SheetSidebar::resizeEvent(QResizeEvent *event) void SheetSidebar::adaptWindowSize(const double &scale) { + qDebug() << "Adapting window size with scale:" << scale; m_scale = scale; BaseWidget *curWidget = dynamic_cast(m_stackLayout->currentWidget()); - if (curWidget) curWidget->adaptWindowSize(scale); + if (curWidget) { + qDebug() << "Adapting widget:" << curWidget->metaObject()->className(); + curWidget->adaptWindowSize(scale); + } } void SheetSidebar::keyPressEvent(QKeyEvent *event) @@ -380,6 +391,7 @@ void SheetSidebar::dealWithPressKey(const QString &sKey) void SheetSidebar::onJumpToPrevPage() { QWidget *curWidget = m_stackLayout->currentWidget(); + qDebug() << "Jumping to previous page in widget:" << (curWidget ? curWidget->metaObject()->className() : "null"); if (curWidget == m_thumbnailWidget) { m_thumbnailWidget->prevPage(); } else if (curWidget == m_bookmarkWidget) { @@ -460,11 +472,13 @@ bool SheetSidebar::event(QEvent *event) void SheetSidebar::onUpdateWidgetTheme() { + qDebug() << "Updating widget theme"; updateWidgetTheme(); for (auto iter = m_btnGroupMap.begin(); iter != m_btnGroupMap.end(); iter++) { const QString &objName = iter.value()->objectName(); const QIcon &icon = QIcon::fromTheme(QString("dr_") + objName); iter.value()->setIcon(icon); + qDebug() << "Updated icon for button:" << objName; } } diff --git a/reader/sidebar/SideBarImageListview.cpp b/reader/sidebar/SideBarImageListview.cpp index e0c09fba..98ea5f19 100644 --- a/reader/sidebar/SideBarImageListview.cpp +++ b/reader/sidebar/SideBarImageListview.cpp @@ -13,11 +13,12 @@ #include #include #include - +#include SideBarImageListView::SideBarImageListView(DocSheet *sheet, QWidget *parent) : DListView(parent) , m_docSheet(sheet) { + qDebug() << "SideBarImageListView created for document:" << (sheet ? sheet->filePath() : "null"); initControl(); setAutoScroll(false); setProperty("adaptScale", 1.0); @@ -32,12 +33,14 @@ SideBarImageListView::SideBarImageListView(DocSheet *sheet, QWidget *parent) setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); QScroller::grabGesture(this, QScroller::TouchGesture);//滑动 + qDebug() << "Enabled touch gesture scrolling"; connect(verticalScrollBar(), &QScrollBar::sliderPressed, this, &SideBarImageListView::onRemoveThumbnailListSlideGesture); - connect(verticalScrollBar(), &QScrollBar::sliderReleased, this, &SideBarImageListView::onSetThumbnailListSlideGesture); + qDebug() << "Connected scrollbar signals"; } + void SideBarImageListView::initControl() { m_pBookMarkMenu = nullptr; @@ -73,6 +76,7 @@ void SideBarImageListView::setListType(int type) void SideBarImageListView::handleOpenSuccess() { + qDebug() << "Handling open success for list type:" << m_listType; if (m_listType == E_SideBar::SIDE_THUMBNIL) { const QSet &pageList = m_docSheet->getBookMarkList(); for (int pageIndex : pageList) { @@ -113,8 +117,12 @@ void SideBarImageListView::handleOpenSuccess() void SideBarImageListView::onItemClicked(const QModelIndex &index) { if (index.isValid()) { - m_docSheet->jumpToIndex(m_imageModel->getPageIndexForModelIndex(index.row())); + int pageIndex = m_imageModel->getPageIndexForModelIndex(index.row()); + qDebug() << "Item clicked at row:" << index.row() << "jumping to page:" << pageIndex; + m_docSheet->jumpToIndex(pageIndex); emit sigListItemClicked(index.row()); + } else { + qWarning() << "Invalid index in onItemClicked"; } } @@ -130,6 +138,7 @@ void SideBarImageListView::onRemoveThumbnailListSlideGesture() bool SideBarImageListView::scrollToIndex(int index, bool scrollTo) { + qDebug() << "Scrolling to index:" << index << "scrollTo:" << scrollTo; const QList &indexlst = m_imageModel->getModelIndexForPageIndex(index); if (indexlst.size() > 0) { const QModelIndex &index = indexlst.first(); @@ -137,8 +146,10 @@ bool SideBarImageListView::scrollToIndex(int index, bool scrollTo) this->scrollTo(index); this->selectionModel()->select(index, QItemSelectionModel::SelectCurrent); this->setCurrentIndex(index); + qDebug() << "Successfully scrolled to model index:" << index.row(); return true; } else { + qWarning() << "No model index found for page index:" << index; this->setCurrentIndex(QModelIndex()); this->clearSelection(); return false; @@ -173,22 +184,27 @@ void SideBarImageListView::mousePressEvent(QMouseEvent *event) void SideBarImageListView::showNoteMenu(const QPoint &point) { + qDebug() << "Showing note menu at:" << point; if (m_pNoteMenu == nullptr) { + qDebug() << "Creating new note menu"; m_pNoteMenu = new DMenu(this); m_pNoteMenu->setAccessibleName("Menu_Note"); QAction *copyAction = m_pNoteMenu->addAction(tr("Copy")); connect(copyAction, &QAction::triggered, [this]() { + qDebug() << "Copy note action triggered"; emit sigListMenuClick(E_NOTE_COPY); }); QAction *delAction = m_pNoteMenu->addAction(tr("Remove annotation")); connect(delAction, &QAction::triggered, [this]() { + qDebug() << "Delete note action triggered"; emit sigListMenuClick(E_NOTE_DELETE); }); QAction *delAllAction = m_pNoteMenu->addAction(tr("Remove all")); connect(delAllAction, &QAction::triggered, [this]() { + qDebug() << "Delete all notes action triggered"; emit sigListMenuClick(E_NOTE_DELETE_ALL); }); } @@ -218,8 +234,10 @@ int SideBarImageListView::getModelIndexForPageIndex(int pageIndex) { const QList &indexlst = m_imageModel->getModelIndexForPageIndex(pageIndex); if (indexlst.size() > 0) { + qDebug() << "Found model index:" << indexlst.first().row() << "for page:" << pageIndex; return indexlst.first().row(); } + qWarning() << "No model index found for page:" << pageIndex; return -1; } diff --git a/reader/sidebar/SideBarImageViewModel.cpp b/reader/sidebar/SideBarImageViewModel.cpp index 06770b4f..f98ccf56 100644 --- a/reader/sidebar/SideBarImageViewModel.cpp +++ b/reader/sidebar/SideBarImageViewModel.cpp @@ -9,7 +9,7 @@ #include "Application.h" #include -#include +#include ImagePageInfo_t::ImagePageInfo_t(int index): pageIndex(index) { @@ -35,11 +35,13 @@ SideBarImageViewModel::SideBarImageViewModel(DocSheet *sheet, QObject *parent) : QAbstractListModel(parent) , m_parent(parent), m_sheet(sheet) { + qDebug() << "SideBarImageViewModel created for document:" << (sheet ? sheet->filePath() : "null"); connect(m_sheet, &DocSheet::sigPageModified, this, &SideBarImageViewModel::onUpdateImage); } void SideBarImageViewModel::resetData() { + qDebug() << "Resetting model data"; beginResetModel(); m_pagelst.clear(); endResetModel(); @@ -47,12 +49,15 @@ void SideBarImageViewModel::resetData() void SideBarImageViewModel::initModelLst(const QList &pagelst, bool sort) { + qDebug() << "Initializing model with" << pagelst.size() << "items, sort:" << sort; beginResetModel(); m_pagelst = pagelst; - if (sort) + if (sort) { + qDebug() << "Sorting model data"; std::sort(m_pagelst.begin(), m_pagelst.end()); + } endResetModel(); } @@ -170,6 +175,7 @@ void SideBarImageViewModel::onUpdateImage(int index) void SideBarImageViewModel::insertPageIndex(int pageIndex) { if (!m_pagelst.contains(ImagePageInfo_t(pageIndex))) { + qDebug() << "Inserting page index:" << pageIndex; int iterIndex = 0; int rowCount = m_pagelst.size(); for (iterIndex = 0; iterIndex < rowCount; iterIndex++) { @@ -180,6 +186,8 @@ void SideBarImageViewModel::insertPageIndex(int pageIndex) m_pagelst.insert(iterIndex, tImageinfo); beginInsertRows(this->index(iterIndex).parent(), iterIndex, iterIndex); endInsertRows(); + } else { + qWarning() << "Page index already exists:" << pageIndex; } } @@ -211,9 +219,12 @@ void SideBarImageViewModel::insertPageIndex(const ImagePageInfo_t &tImagePageInf void SideBarImageViewModel::removePageIndex(int pageIndex) { if (m_pagelst.contains(ImagePageInfo_t(pageIndex))) { + qDebug() << "Removing page index:" << pageIndex; beginResetModel(); m_pagelst.removeAll(ImagePageInfo_t(pageIndex)); endResetModel(); + } else { + qWarning() << "Page index not found:" << pageIndex; } } @@ -247,10 +258,12 @@ int SideBarImageViewModel::findItemForAnno(deepin_reader::Annotation *annotation void SideBarImageViewModel::handleRenderThumbnail(int index, QPixmap pixmap) { + qDebug() << "Handling thumbnail render for page:" << index << "size:" << pixmap.size(); pixmap.setDevicePixelRatio(dApp->devicePixelRatio()); m_sheet->setThumbnail(index, pixmap); const QList &modelIndexlst = getModelIndexForPageIndex(index); + qDebug() << "Notifying" << modelIndexlst.size() << "views of data change"; for (const QModelIndex &modelIndex : modelIndexlst) emit dataChanged(modelIndex, modelIndex); } diff --git a/reader/sidebar/ThumbnailDelegate.cpp b/reader/sidebar/ThumbnailDelegate.cpp index 96f8d5ce..9f95c872 100644 --- a/reader/sidebar/ThumbnailDelegate.cpp +++ b/reader/sidebar/ThumbnailDelegate.cpp @@ -9,21 +9,24 @@ #include "Application.h" #include +#include #include #include #include #include #include - ThumbnailDelegate::ThumbnailDelegate(QAbstractItemView *parent) : DStyledItemDelegate(parent) { + qDebug() << "ThumbnailDelegate created with parent:" << parent; m_parent = parent; } + void ThumbnailDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + qDebug() << "Painting thumbnail for row:" << index.row(); if (index.isValid()) { qreal pixscale = m_parent->property("adaptScale").toDouble(); @@ -77,16 +80,19 @@ void ThumbnailDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt drawBookMark(painter, rect, bShowBookMark); } } - QSize ThumbnailDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { + qDebug() << "Calculating size hint for row:" << index.row(); return DStyledItemDelegate::sizeHint(option, index); } void ThumbnailDelegate::drawBookMark(QPainter *painter, const QRect &rect, bool visible) const { if (visible) { + qDebug() << "Drawing bookmark at:" << rect; QPixmap pixmap(QIcon::fromTheme("dr_bookmark_checked").pixmap({36, 36})); painter->drawPixmap(rect.right() - 42, rect.y(), pixmap); + } else { + qDebug() << "Bookmark not visible for rect:" << rect; } } diff --git a/reader/sidebar/ThumbnailWidget.cpp b/reader/sidebar/ThumbnailWidget.cpp index 66e272fb..09fe5c05 100644 --- a/reader/sidebar/ThumbnailWidget.cpp +++ b/reader/sidebar/ThumbnailWidget.cpp @@ -12,15 +12,16 @@ #include "ThumbnailDelegate.h" #include +#include #include const int LEFTMINHEIGHT = 220; - ThumbnailWidget::ThumbnailWidget(DocSheet *sheet, DWidget *parent) : BaseWidget(parent) , m_sheet(sheet) { + qDebug() << "ThumbnailWidget created for document:" << (sheet ? sheet->filePath() : "null"); initWidget(); } @@ -31,6 +32,7 @@ ThumbnailWidget::~ThumbnailWidget() void ThumbnailWidget::initWidget() { + qDebug() << "Initializing ThumbnailWidget UI"; m_pImageListView = new SideBarImageListView(m_sheet, this); m_pImageListView->setAccessibleName("View_ImageList"); ThumbnailDelegate *imageDelegate = new ThumbnailDelegate(m_pImageListView); @@ -53,8 +55,11 @@ void ThumbnailWidget::initWidget() void ThumbnailWidget::handleOpenSuccess() { - if (bIshandOpenSuccess) + if (bIshandOpenSuccess) { + qDebug() << "Already handled open success"; return; + } + qDebug() << "Handling document open success"; bIshandOpenSuccess = true; m_pImageListView->handleOpenSuccess(); m_pPageWidget->handleOpenSuccess(); @@ -75,6 +80,7 @@ void ThumbnailWidget::handlePage(int index) void ThumbnailWidget::setBookMarkState(const int &index, const int &type) { + qDebug() << "Setting bookmark state for page:" << index << "type:" << type; m_pImageListView->getImageModel()->setBookMarkVisible(index, type); } @@ -116,8 +122,11 @@ void ThumbnailWidget::pageDown() void ThumbnailWidget::adaptWindowSize(const double &scale) { + qDebug() << "Adapting window size with scale:" << scale; m_pImageListView->setProperty("adaptScale", scale); - m_pImageListView->setItemSize(QSize(static_cast(LEFTMINWIDTH * scale), static_cast(qMax(LEFTMINHEIGHT * scale, LEFTMINHEIGHT * 1.0)))); + QSize newSize(static_cast(LEFTMINWIDTH * scale), static_cast(qMax(LEFTMINHEIGHT * scale, LEFTMINHEIGHT * 1.0))); + qDebug() << "Setting new item size:" << newSize; + m_pImageListView->setItemSize(newSize); m_pImageListView->reset(); scrollToCurrentPage(); } diff --git a/reader/uiframe/Central.cpp b/reader/uiframe/Central.cpp index fd528236..418d849a 100644 --- a/reader/uiframe/Central.cpp +++ b/reader/uiframe/Central.cpp @@ -24,6 +24,7 @@ Central::Central(QWidget *parent) : BaseWidget(parent) { + qDebug() << "Central widget initializing..."; setAcceptDrops(true); m_widget = new TitleWidget(parent); @@ -86,6 +87,7 @@ Central::Central(QWidget *parent) Central::~Central() { + qDebug() << "Central widget destroying..."; } TitleWidget *Central::titleWidget() @@ -119,18 +121,21 @@ void Central::setMenu(TitleMenu *menu) void Central::addFilesWithDialog() { + qDebug() << "Opening file selection dialog..."; DFileDialog dialog(this); dialog.setFileMode(DFileDialog::ExistingFiles); dialog.setNameFilter(tr("Documents") + " (*.pdf *.djvu *.docx)"); dialog.setDirectory(QDir::homePath()); if (QDialog::Accepted != dialog.exec()) { + qDebug() << "File selection dialog canceled"; return; } QStringList filePathList = dialog.selectedFiles(); if (filePathList.count() <= 0) { + qWarning() << "No files selected in dialog"; return; } @@ -148,6 +153,7 @@ void Central::addFilesWithDialog() void Central::addFileAsync(const QString &filePath) { + qDebug() << "Adding file asynchronously:" << filePath; docPage()->addFileAsync(filePath); } @@ -177,6 +183,7 @@ QList Central::getSheets() void Central::handleShortcut(const QString &shortcut) { if (shortcut == Dr::key_ctrl_o) { + qDebug() << "Handling Ctrl+O shortcut - opening file dialog"; addFilesWithDialog(); } if (shortcut == Dr::key_ctrl_shift_slash) { // 显示快捷键预览 ShortCutShow show; @@ -193,6 +200,7 @@ bool Central::handleClose(bool needToBeSaved) qDebug() << __FUNCTION__ << "正在关闭所有 sheet ..."; return docPage()->closeAllSheets(needToBeSaved); } + qWarning() << "No document page available to close"; return true; } @@ -233,6 +241,7 @@ void Central::onMenuTriggered(const QString &action) void Central::onOpenFilesExec() { + qDebug() << "Executing open files request"; addFilesWithDialog(); } @@ -284,8 +293,10 @@ void Central::onTouchPadEvent(const QString &name, const QString &direction, int void Central::onKeyTriggered() { QAction *action = static_cast(sender()); - if (nullptr == action) + if (nullptr == action) { + qWarning() << "Received key trigger from null action"; return; + } handleShortcut(action->shortcut().toString()); } @@ -343,6 +354,7 @@ void Central::dropEvent(QDropEvent *event) void Central::resizeEvent(QResizeEvent *event) { + qDebug() << "Handling resize event to size:" << event->size(); m_mainWidget->move(0, 0); m_mainWidget->resize(event->size()); BaseWidget::resizeEvent(event); diff --git a/reader/uiframe/CentralDocPage.cpp b/reader/uiframe/CentralDocPage.cpp index cb3683ab..71754e74 100644 --- a/reader/uiframe/CentralDocPage.cpp +++ b/reader/uiframe/CentralDocPage.cpp @@ -85,6 +85,7 @@ static bool pathControl(const QString &sPath) noexcept CentralDocPage::CentralDocPage(DWidget *parent) : BaseWidget(parent) { + qDebug() << "Initializing CentralDocPage..."; m_tabBar = new DocTabBar(this); connect(m_tabBar, SIGNAL(sigTabChanged(DocSheet *)), this, SLOT(onTabChanged(DocSheet *))); connect(m_tabBar, SIGNAL(sigTabMoveIn(DocSheet *)), this, SLOT(onTabMoveIn(DocSheet *))); @@ -127,6 +128,7 @@ CentralDocPage::CentralDocPage(DWidget *parent) CentralDocPage::~CentralDocPage() { + qDebug() << "Destroying CentralDocPage..."; } bool CentralDocPage::firstThumbnail(QString filePath, QString thumbnailPath) @@ -145,8 +147,10 @@ bool CentralDocPage::firstThumbnail(QString filePath, QString thumbnailPath) void CentralDocPage::openCurFileFolder() { DocSheet *sheet = getCurSheet(); - if (nullptr == sheet) + if (nullptr == sheet) { + qWarning() << "No current sheet to open folder for"; return; + } QString filePath = sheet->filePath(); QUrl displayUrl = QUrl(filePath); @@ -246,6 +250,7 @@ void CentralDocPage::addFileAsync(const QString &filePath) void CentralDocPage::onOpened(DocSheet *sheet, deepin_reader::Document::Error error) { if (deepin_reader::Document::FileError == error || deepin_reader::Document::FileDamaged == error || deepin_reader::Document::ConvertFailed == error) { + qWarning() << "Failed to open document:" << sheet->filePath() << "Error:" << error; m_stackedLayout->removeWidget(sheet); m_tabBar->removeSheet(sheet); @@ -467,10 +472,13 @@ QList CentralDocPage::getSheets() bool CentralDocPage::saveCurrent() { + qDebug() << "Attempting to save current document"; DocSheet *sheet = qobject_cast(m_stackedLayout->currentWidget()); - if (nullptr == sheet) + if (nullptr == sheet) { + qWarning() << "No current sheet to save"; return false; + } if (!sheet->fileChanged()) { return false; @@ -495,6 +503,7 @@ bool CentralDocPage::saveCurrent() bool CentralDocPage::saveAsCurrent() { + qDebug() << "Attempting to save current document as..."; DocSheet *sheet = getCurSheet(); if (nullptr == sheet) @@ -677,6 +686,7 @@ void CentralDocPage::showTips(QWidget *parent, const QString &tips, int iconInde void CentralDocPage::openMagnifer() { + qDebug() << "Opening magnifier tool"; quitMagnifer(); m_magniferSheet = getCurSheet(); @@ -696,6 +706,7 @@ void CentralDocPage::quitMagnifer() void CentralDocPage::openSlide() { + qDebug() << "Opening slide mode"; DocSheet *docSheet = getCurSheet(); if (docSheet && docSheet->opened() && m_slideWidget == nullptr) { m_slideWidget = new SlideWidget(getCurSheet()); @@ -827,6 +838,7 @@ QWidget *CentralDocPage::getTitleLabel() void CentralDocPage::handleBlockShutdown() { + qDebug() << "Checking if need to block shutdown"; bool bBlock = false; QList sheets = m_tabBar->getSheets(); @@ -839,8 +851,10 @@ void CentralDocPage::handleBlockShutdown() } if (bBlock) { + qInfo() << "Blocking shutdown due to unsaved documents"; DBusObject::instance()->blockShutdown(); // 存在未保存的文档时阻塞关机 } else { + qDebug() << "No need to block shutdown"; DBusObject::instance()->unBlockShutdown(); // 所有文档都保存的情况下不阻塞关机 } } diff --git a/reader/uiframe/CentralNavPage.cpp b/reader/uiframe/CentralNavPage.cpp index 0de7315d..8842774e 100644 --- a/reader/uiframe/CentralNavPage.cpp +++ b/reader/uiframe/CentralNavPage.cpp @@ -17,6 +17,7 @@ CentralNavPage::CentralNavPage(DWidget *parent) : BaseWidget(parent) { + qDebug() << "Initializing CentralNavPage..."; auto tipsLabel = new DLabel(tr("Drag documents here"), this); tipsLabel->setAccessibleName("Label_Drag documents here"); tipsLabel->setAlignment(Qt::AlignHCenter); @@ -70,6 +71,7 @@ CentralNavPage::CentralNavPage(DWidget *parent) // 主题切换 void CentralNavPage::onThemeChanged() { + qDebug() << "Theme changed, updating UI"; auto iconSvg = this->findChild("iconSvg"); if (iconSvg) { auto plt = Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette(); diff --git a/reader/uiframe/DocSheet.cpp b/reader/uiframe/DocSheet.cpp index 71601a5e..c5394f99 100644 --- a/reader/uiframe/DocSheet.cpp +++ b/reader/uiframe/DocSheet.cpp @@ -52,6 +52,7 @@ QString DocSheet::g_lastOperationFile; DocSheet::DocSheet(const Dr::FileType &fileType, const QString &filePath, QWidget *parent) : DSplitter(parent), m_filePath(filePath), m_fileType(fileType) { + qDebug() << "Creating DocSheet for file:" << filePath; setAlive(true); setHandleWidth(5); setChildrenCollapsible(false); // 子部件不可拉伸到 0 @@ -212,9 +213,14 @@ QList DocSheet::getSheets() bool DocSheet::openFileExec(const QString &password) { + qDebug() << "Executing file open synchronously"; m_password = password; - return m_renderer->openFileExec(password); + bool result = m_renderer->openFileExec(password); + if (!result) { + qWarning() << "Failed to open file synchronously"; + } + return result; } void DocSheet::openFileAsync(const QString &password) @@ -227,6 +233,7 @@ void DocSheet::openFileAsync(const QString &password) void DocSheet::jumpToPage(int page) { + qDebug() << "Jumping to page:" << page; m_browser->setCurrentPage(page); } @@ -449,9 +456,9 @@ bool DocSheet::fileChanged() { return (m_documentChanged || m_bookmarkChanged); } - bool DocSheet::saveData() { + qDebug() << "Saving document data"; PERF_PRINT_BEGIN("POINT-04", QString("filename=%1,filesize=%2").arg(QFileInfo(this->filePath()).fileName()).arg(QFileInfo(this->filePath()).size())); //文档改变或者原文档被删除 则进行数据保存 @@ -469,9 +476,9 @@ bool DocSheet::saveData() return true; } - bool DocSheet::saveAsData(QString targetFilePath) { + qDebug() << "Saving document as:" << targetFilePath; stopSearch(); if (m_documentChanged && Dr::DOCX != fileType()) { @@ -738,8 +745,11 @@ void DocSheet::showTips(const QString &tips, int iconIndex) void DocSheet::onPrintRequested(DPrinter *printer, const QVector &pageRange) { - if (pageRange.isEmpty()) + qDebug() << "Print requested for pages:" << pageRange; + if (pageRange.isEmpty()) { + qWarning() << "Empty page range for printing"; return; + } //后台加载动画 QWidget *pCurWgt = nullptr; @@ -1281,6 +1291,7 @@ QString DocSheet::getPageLabelByIndex(const int &index) void DocSheet::onExtractPassword(const QString &password) { + qDebug() << "Extracted password, attempting to open file"; m_password = password; m_renderer->openFileAsync(m_password); @@ -1293,8 +1304,11 @@ SheetRenderer *DocSheet::renderer() void DocSheet::onPopPrintDialog() { - if (!this->opened()) + qDebug() << "Preparing print dialog"; + if (!this->opened()) { + qWarning() << "Cannot print - document not opened"; return; + } DPrintPreviewDialog *preview = new DPrintPreviewDialog(this); preview->setAttribute(Qt::WA_DeleteOnClose); diff --git a/reader/uiframe/DocTabBar.cpp b/reader/uiframe/DocTabBar.cpp index 0e4dc1de..428d6fd4 100644 --- a/reader/uiframe/DocTabBar.cpp +++ b/reader/uiframe/DocTabBar.cpp @@ -20,6 +20,7 @@ DocTabBar::DocTabBar(QWidget *parent) : DTabBar(parent) { + qDebug() << "Initializing DocTabBar..."; #if (DTK_VERSION_MAJOR > 5 || (DTK_VERSION_MAJOR >= 5 && DTK_VERSION_MINOR >= 2 )) this->setEnabledEmbedStyle(true);//设置直角样式 this->setExpanding(true);//设置平铺窗口模式 @@ -68,8 +69,10 @@ int DocTabBar::indexOfFilePath(const QString &filePath) void DocTabBar::insertSheet(DocSheet *sheet, int index) { - if (sheet == nullptr) + if (sheet == nullptr) { + qWarning() << "Cannot insert null sheet"; return; + } QString fileName = QFileInfo(sheet->filePath()).fileName(); @@ -91,6 +94,7 @@ void DocTabBar::insertSheet(DocSheet *sheet, int index) void DocTabBar::removeSheet(DocSheet *sheet) { + qDebug() << "Removing sheet:" << (sheet ? sheet->filePath() : "null"); for (int i = 0; i < count(); ++i) { if (DocSheet::getSheet(this->tabData(i).toString()) == sheet) { removeTab(i); @@ -98,6 +102,7 @@ void DocTabBar::removeSheet(DocSheet *sheet) return; } } + qWarning() << "Sheet not found in tab bar"; } void DocTabBar::showSheet(DocSheet *sheet) @@ -245,16 +250,24 @@ void DocTabBar::onDragActionChanged(Qt::DropAction action) void DocTabBar::onTabChanged(int index) { + qDebug() << "Tab changed to index:" << index; QString id = tabData(index).toString(); - - sigTabChanged(DocSheet::getSheet(id)); - + DocSheet *sheet = DocSheet::getSheet(id); + if (sheet) { + qInfo() << "Switched to sheet:" << sheet->filePath(); + } else { + qWarning() << "No sheet found for tab index:" << index; + } + sigTabChanged(sheet); } void DocTabBar::onTabReleased(int) { - if (count() <= 1) + qDebug() << "Tab released"; + if (count() <= 1) { + qDebug() << "Only one tab, ignoring release"; return; + } int dropIndex = currentIndex(); //使用dropIndex替代index ,因为index是记录刚drag的index,当拖拽的时候几个item被移动了就会出错 @@ -300,8 +313,11 @@ void DocTabBar::onSetCurrentIndex() void DocTabBar::onTabCloseRequested(int index) { - if (m_intervalTimer->isActive()) + qDebug() << "Tab close requested for index:" << index; + if (m_intervalTimer->isActive()) { + qDebug() << "Close operation throttled, ignoring"; return; + } DocSheet *sheet = DocSheet::getSheet(this->tabData(index).toString()); diff --git a/reader/uiframe/SheetRenderer.cpp b/reader/uiframe/SheetRenderer.cpp index 425736f4..aa69f676 100644 --- a/reader/uiframe/SheetRenderer.cpp +++ b/reader/uiframe/SheetRenderer.cpp @@ -10,7 +10,7 @@ SheetRenderer::SheetRenderer(DocSheet *parent) : QObject(parent), m_sheet(parent) { - + qDebug() << "Creating SheetRenderer for sheet:" << (parent ? parent->filePath() : "null"); } SheetRenderer::~SheetRenderer() @@ -28,6 +28,7 @@ SheetRenderer::~SheetRenderer() bool SheetRenderer::openFileExec(const QString &password) { + qDebug() << "Executing synchronous file open"; QEventLoop loop; connect(this, &SheetRenderer::sigOpened, &loop, &QEventLoop::quit); @@ -36,11 +37,16 @@ bool SheetRenderer::openFileExec(const QString &password) loop.exec(); - return deepin_reader::Document::NoError == m_error; + bool success = deepin_reader::Document::NoError == m_error; + if (!success) { + qWarning() << "Failed to open file synchronously, error:" << m_error; + } + return success; } void SheetRenderer::openFileAsync(const QString &password) { + qDebug() << "Starting asynchronous file open"; DocOpenTask task; task.sheet = m_sheet; @@ -196,10 +202,17 @@ deepin_reader::Properties SheetRenderer::properties() const bool SheetRenderer::save() { - if (m_document == nullptr) + qDebug() << "Attempting to save document"; + if (m_document == nullptr) { + qWarning() << "Cannot save - no document loaded"; return false; + } - return m_document->save(); + bool success = m_document->save(); + if (!success) { + qWarning() << "Failed to save document"; + } + return success; } void SheetRenderer::loadPageLable() @@ -254,14 +267,26 @@ QString SheetRenderer::pageNum2Lable(const int index) bool SheetRenderer::saveAs(const QString &filePath) { - if (filePath.isEmpty() || m_document == nullptr) + qDebug() << "Attempting to save document as:" << filePath; + if (filePath.isEmpty()) { + qWarning() << "Cannot save - empty file path"; return false; + } + if (m_document == nullptr) { + qWarning() << "Cannot save - no document loaded"; + return false; + } - return m_document->saveAs(filePath);; + bool success = m_document->saveAs(filePath); + if (!success) { + qWarning() << "Failed to save document as:" << filePath; + } + return success; } void SheetRenderer::handleOpened(deepin_reader::Document::Error error, deepin_reader::Document *document, QList pages) { + qDebug() << "Document opened with error:" << error; m_error = error; m_document = document; diff --git a/reader/uiframe/TitleMenu.cpp b/reader/uiframe/TitleMenu.cpp index 14b365df..17d6f860 100644 --- a/reader/uiframe/TitleMenu.cpp +++ b/reader/uiframe/TitleMenu.cpp @@ -11,6 +11,7 @@ TitleMenu::TitleMenu(DWidget *parent) : DMenu(parent) { + qDebug() << "Initializing TitleMenu..."; QStringList firstActionList = QStringList() << tr("New window") << tr("New tab"); QStringList firstActionObjList = QStringList() << "New window" << "New tab"; createActionMap(firstActionList, firstActionObjList); @@ -44,7 +45,9 @@ TitleMenu::TitleMenu(DWidget *parent) void TitleMenu::onCurSheetChanged(DocSheet *sheet) { + qDebug() << "Current sheet changed"; if (nullptr == sheet || !sheet->opened()) { + qWarning() << "Invalid sheet, disabling all actions"; disableAllAction(); return; } @@ -70,30 +73,38 @@ void TitleMenu::onCurSheetChanged(DocSheet *sheet) void TitleMenu::onActionTriggered() { QAction *action = static_cast(sender()); - if (nullptr == action) + if (nullptr == action) { + qWarning() << "Action triggered but sender is null"; return; + } + qDebug() << "Menu action triggered:" << action->objectName(); emit sigActionTriggered(action->objectName()); } void TitleMenu::disableAllAction() { + qDebug() << "Disabling all menu actions"; QStringList actiontextlist; actiontextlist << "Save" << "Save as" << "Display in file manager" << "Magnifer" << "Search" << "Print"; const QList &actions = this->findChildren(); foreach (QAction *a, actions) { - if (actiontextlist.indexOf(a->objectName()) != -1) + if (actiontextlist.indexOf(a->objectName()) != -1) { a->setDisabled(true); + qDebug() << "Disabled action:" << a->objectName(); + } } m_handleMenu->setDisabled(true); } void TitleMenu::disableSaveButton(bool disable) { + qDebug() << (disable ? "Disabling" : "Enabling") << "Save button"; const QList &actions = this->findChildren(); foreach (QAction *a, actions) { if (a->text() == tr("Save")) { a->setDisabled(disable); + qDebug() << "Save button state:" << (disable ? "disabled" : "enabled"); break; } } diff --git a/reader/uiframe/TitleWidget.cpp b/reader/uiframe/TitleWidget.cpp index c783f023..e6a6b30e 100644 --- a/reader/uiframe/TitleWidget.cpp +++ b/reader/uiframe/TitleWidget.cpp @@ -15,6 +15,7 @@ TitleWidget::TitleWidget(DWidget *parent) : BaseWidget(parent) { + qDebug() << "Initializing TitleWidget..."; m_pThumbnailBtn = new DIconButton(this); m_pThumbnailBtn->setObjectName("Thumbnails"); m_pThumbnailBtn->setToolTip(tr("Thumbnails")); @@ -89,7 +90,7 @@ TitleWidget::TitleWidget(DWidget *parent) TitleWidget::~TitleWidget() { - + qDebug() << "Destroying TitleWidget..."; } void TitleWidget::keyPressEvent(QKeyEvent *event) @@ -114,28 +115,33 @@ void TitleWidget::setBtnDisable(const bool &bAble) void TitleWidget::onCurSheetChanged(DocSheet *sheet) { + qDebug() << "Current sheet changed"; m_curSheet = sheet; emit dApp->emitSheetChanged(); if (nullptr == m_curSheet || m_curSheet->fileType() == Dr::Unknown) { + qWarning() << "Invalid sheet, disabling controls"; setBtnDisable(true); return; + } - } else if (Dr::PDF == m_curSheet->fileType() || Dr::DOCX == m_curSheet->fileType()) { + qDebug() << "Setting up controls for file type:" << m_curSheet->fileType(); + if (Dr::PDF == m_curSheet->fileType() || Dr::DOCX == m_curSheet->fileType()) { if (m_curSheet->opened()) { + qDebug() << "Document opened, enabling controls"; setBtnDisable(false); m_pThumbnailBtn->setChecked(m_curSheet->operation().sidebarVisible); } else { + qDebug() << "Document not opened, disabling controls"; setBtnDisable(true); m_pThumbnailBtn->setChecked(false); } m_pSw->setSheet(m_curSheet); - } else if (Dr::DJVU == m_curSheet->fileType()) { + qDebug() << "DJVU document, setting up controls"; m_pThumbnailBtn->setDisabled(false); m_pSw->setDisabled(false); - m_pThumbnailBtn->setChecked(m_curSheet->operation().sidebarVisible); m_pSw->setSheet(m_curSheet); } @@ -143,11 +149,15 @@ void TitleWidget::onCurSheetChanged(DocSheet *sheet) void TitleWidget::onThumbnailBtnClicked(bool checked) { - if (m_curSheet.isNull()) + if (m_curSheet.isNull()) { + qWarning() << "Thumbnail button clicked but no current sheet"; return; + } + qDebug() << "Thumbnail button clicked, checked:" << checked; m_pThumbnailBtn->setChecked(checked); bool rl = m_pThumbnailBtn->isChecked(); + qDebug() << "Setting sidebar visibility to:" << rl; m_curSheet->setSidebarVisible(rl); } @@ -165,6 +175,7 @@ void TitleWidget::onFindOperation(const int &sAction) void TitleWidget::setControlEnabled(const bool &enable) { + qDebug() << "Setting controls enabled:" << enable; m_pThumbnailBtn->setChecked(false); m_pThumbnailBtn->setEnabled(enable); m_pSw->clear(); diff --git a/reader/widgets/AttrScrollWidget.cpp b/reader/widgets/AttrScrollWidget.cpp index bf79f0b2..eb0ce9a3 100644 --- a/reader/widgets/AttrScrollWidget.cpp +++ b/reader/widgets/AttrScrollWidget.cpp @@ -7,6 +7,7 @@ #include "Utils.h" #include "DocSheet.h" #include "WordWrapLabel.h" +#include #include #include @@ -18,6 +19,7 @@ DWIDGET_USE_NAMESPACE AttrScrollWidget::AttrScrollWidget(DocSheet *sheet, DWidget *parent) : DFrame(parent) { + qDebug() << "AttrScrollWidget constructor start, sheet:" << sheet; setFrameShape(QFrame::NoFrame); installEventFilter(this); @@ -56,10 +58,12 @@ AttrScrollWidget::AttrScrollWidget(DocSheet *sheet, DWidget *parent) vLayout->addStretch(1); this->setLayout(vLayout); + qDebug() << "AttrScrollWidget constructor end"; } void AttrScrollWidget::createLabel(QGridLayout *layout, const int &index, const QString &objName, const QString &sData) { + qDebug() << "Create label for" << objName << "with text data"; DLabel *label = new DLabel(objName, this); DFontSizeManager::instance()->bind(label, DFontSizeManager::T8); label->setAlignment(Qt::AlignTop); @@ -82,6 +86,7 @@ void AttrScrollWidget::createLabel(QGridLayout *layout, const int &index, const void AttrScrollWidget::createLabel(QGridLayout *layout, const int &index, const QString &objName, const QDateTime &sData) { + qDebug() << "Create label for" << objName << "with datetime data"; DLabel *label = new DLabel(objName, this); DFontSizeManager::instance()->bind(label, DFontSizeManager::T8); label->setAlignment(Qt::AlignTop); @@ -102,6 +107,7 @@ void AttrScrollWidget::createLabel(QGridLayout *layout, const int &index, const void AttrScrollWidget::createLabel(QGridLayout *layout, const int &index, const QString &objName, const bool &bData) { + qDebug() << "Create label for" << objName << "with boolean data"; DLabel *label = new DLabel(objName, this); DFontSizeManager::instance()->bind(label, DFontSizeManager::T8); label->setAlignment(Qt::AlignTop); @@ -119,6 +125,7 @@ void AttrScrollWidget::createLabel(QGridLayout *layout, const int &index, const bool AttrScrollWidget::eventFilter(QObject *object, QEvent *event) { + qDebug() << "Event filter triggered, type:" << event->type(); if (object == this) { if (event->type() == QEvent::Resize) { QLocale locale; @@ -138,5 +145,7 @@ bool AttrScrollWidget::eventFilter(QObject *object, QEvent *event) widget->setFixedWidth(240 - leftMinwidth); } } - return DFrame::eventFilter(object, event); + bool result = DFrame::eventFilter(object, event); + qDebug() << "Event filter processed, result:" << result; + return result; } diff --git a/reader/widgets/BaseWidget.cpp b/reader/widgets/BaseWidget.cpp index 909eff2b..fd30deb0 100644 --- a/reader/widgets/BaseWidget.cpp +++ b/reader/widgets/BaseWidget.cpp @@ -4,30 +4,35 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "BaseWidget.h" +#include #include BaseWidget::BaseWidget(DWidget *parent) : DWidget(parent) { + qDebug() << "BaseWidget created, parent:" << parent; setAutoFillBackground(true); setFocusPolicy(Qt::StrongFocus); setContextMenuPolicy(Qt::CustomContextMenu); + qDebug() << "Widget theme updated"; } BaseWidget::~BaseWidget() { - + qDebug() << "BaseWidget destroyed"; } + void BaseWidget::updateWidgetTheme() { + qDebug() << "Updating widget theme"; Dtk::Gui::DPalette plt = Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette(); plt.setColor(Dtk::Gui::DPalette::Window, plt.color(Dtk::Gui::DPalette::Base)); setPalette(plt); } -void BaseWidget::adaptWindowSize(const double &) +void BaseWidget::adaptWindowSize(const double &ratio) { - + qDebug() << "adaptWindowSize called with ratio:" << ratio; } diff --git a/reader/widgets/ColorWidgetAction.cpp b/reader/widgets/ColorWidgetAction.cpp index 87e9d548..96f8b474 100644 --- a/reader/widgets/ColorWidgetAction.cpp +++ b/reader/widgets/ColorWidgetAction.cpp @@ -7,6 +7,7 @@ #include "Application.h" #include "Utils.h" #include "RoundColorWidget.h" +#include #include @@ -17,12 +18,14 @@ ColorWidgetAction::ColorWidgetAction(DWidget *pParent) : QWidgetAction(pParent) { + qDebug() << "ColorWidgetAction created, parent:" << pParent; initWidget(pParent); setSeparator(true); } void ColorWidgetAction::slotBtnClicked(int index) { + qDebug() << "Color button clicked, index:" << index; auto btnList = this->defaultWidget()->findChildren(); foreach (auto btn, btnList) { int btnIndex = btn->objectName().toInt(); @@ -35,10 +38,12 @@ void ColorWidgetAction::slotBtnClicked(int index) btn->setSelected(false); } } + qDebug() << "Highlight color changed to index:" << index; } void ColorWidgetAction::initWidget(DWidget *pParent) { + qDebug() << "Initializing color widget with" << Utils::getHiglightColorList().size() << "colors"; DWidget *pWidget = new DWidget(pParent); setDefaultWidget(pWidget); @@ -63,6 +68,7 @@ void ColorWidgetAction::initWidget(DWidget *pParent) sigMap->setMapping(btn, iLoop); buttonLayout->addWidget(btn); + qDebug() << "Color widget initialization completed"; } connect(sigMap, SIGNAL(mapped(int)), SLOT(slotBtnClicked(int))); diff --git a/reader/widgets/EncryptionPage.cpp b/reader/widgets/EncryptionPage.cpp index 4d655a29..9dce3ef9 100644 --- a/reader/widgets/EncryptionPage.cpp +++ b/reader/widgets/EncryptionPage.cpp @@ -6,6 +6,7 @@ #include "EncryptionPage.h" #include "Utils.h" #include "Application.h" +#include #include #include @@ -16,17 +17,19 @@ EncryptionPage::EncryptionPage(QWidget *parent) : DWidget(parent) { + qDebug() << "EncryptionPage created, parent:" << parent; InitUI(); InitConnection(); } EncryptionPage::~EncryptionPage() { - + qDebug() << "EncryptionPage destroyed"; } void EncryptionPage::InitUI() { + qDebug() << "Initializing encryption page UI"; QPixmap m_encrypticon = QIcon::fromTheme("dr_compress_lock").pixmap(128, 128); DLabel *pixmaplabel = new DLabel(this); pixmaplabel->setPixmap(m_encrypticon); @@ -70,10 +73,12 @@ void EncryptionPage::InitUI() onUpdateTheme(); m_password->lineEdit()->setAttribute(Qt::WA_InputMethodEnabled, false); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &EncryptionPage::onUpdateTheme); + qDebug() << "Encryption page UI initialized"; } void EncryptionPage::InitConnection() { + qDebug() << "Setting up encryption page signal connections"; connect(m_password, &DPasswordEdit::textChanged, this, &EncryptionPage::onPasswordChanged); connect(m_nextbutton, &DPushButton::clicked, this, &EncryptionPage::nextbuttonClicked); @@ -82,11 +87,13 @@ void EncryptionPage::InitConnection() void EncryptionPage::nextbuttonClicked() { + qDebug() << "Password submitted (length:" << m_password->text().length() << "chars)"; emit sigExtractPassword(m_password->text()); } void EncryptionPage::wrongPassWordSlot() { + qWarning() << "Wrong password entered"; m_password->clear(); m_password->setAlert(true); m_password->showAlertMessage(tr("Wrong password")); @@ -95,9 +102,11 @@ void EncryptionPage::wrongPassWordSlot() void EncryptionPage::onPasswordChanged() { + qDebug() << "Password field changed, empty:" << m_password->text().isEmpty(); if (m_password->isAlert()) { m_password->setAlert(false); m_password->hideAlertMessage(); + qDebug() << "Encryption page theme updated"; } if (m_password->text().isEmpty()) { @@ -115,6 +124,7 @@ void EncryptionPage::onSetPasswdFocus() void EncryptionPage::onUpdateTheme() { + qDebug() << "Updating encryption page theme"; DPalette plt = Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette(); plt.setColor(Dtk::Gui::DPalette::Window, plt.color(Dtk::Gui::DPalette::Base)); setPalette(plt); diff --git a/reader/widgets/FileAttrWidget.cpp b/reader/widgets/FileAttrWidget.cpp index 37f7a355..fcd931b1 100644 --- a/reader/widgets/FileAttrWidget.cpp +++ b/reader/widgets/FileAttrWidget.cpp @@ -10,6 +10,7 @@ #include "DocSheet.h" #include "MsgHeader.h" #include "Utils.h" +#include #include #include @@ -55,6 +56,7 @@ void ImageWidget::paintEvent(QPaintEvent *event) FileAttrWidget::FileAttrWidget(DWidget *parent) : DAbstractDialog(parent) { + qDebug() << "FileAttrWidget created, parent:" << parent; setFixedSize(QSize(300, 622)); m_pVBoxLayout = new QVBoxLayout; m_pVBoxLayout->setContentsMargins(0, 0, 0, 10); @@ -64,10 +66,12 @@ FileAttrWidget::FileAttrWidget(DWidget *parent) FileAttrWidget::~FileAttrWidget() { + qDebug() << "FileAttrWidget destroyed"; } void FileAttrWidget::setFileAttr(DocSheet *sheet) { + qDebug() << "Setting file attributes for sheet:" << (sheet ? "valid" : "null"); if (sheet == nullptr) return; @@ -118,6 +122,7 @@ void FileAttrWidget::setFileAttr(DocSheet *sheet) scrolllayout->addWidget(infoframe); m_pVBoxLayout->addLayout(scrolllayout, 1); + qDebug() << "File attributes set, image loaded:" << (!image.isNull() ? "success" : "failed"); } void FileAttrWidget::addTitleFrame(const QString &sData) @@ -134,12 +139,14 @@ void FileAttrWidget::addTitleFrame(const QString &sData) void FileAttrWidget::showScreenCenter() { + qDebug() << "Showing file attribute widget at screen center"; Dtk::Widget::moveToCenter(this); this->show(); } void FileAttrWidget::initWidget() { + qDebug() << "Initializing file attribute widget"; initCloseBtn(); initImageLabel(); } @@ -163,6 +170,7 @@ void FileAttrWidget::initCloseBtn() } else { closeButton->setFixedSize(QSize(40, 40)); closeButton->setIconSize(QSize(40, 40)); + qDebug() << "File attribute widget initialization completed"; } connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { if (sizeMode == DGuiApplicationHelper::NormalMode) { diff --git a/reader/widgets/FindWidget.cpp b/reader/widgets/FindWidget.cpp index 600ced7f..aa3a02df 100644 --- a/reader/widgets/FindWidget.cpp +++ b/reader/widgets/FindWidget.cpp @@ -7,6 +7,7 @@ #include "BaseWidget.h" #include "DocSheet.h" #include "Utils.h" +#include #include #include @@ -19,6 +20,7 @@ FindWidget::FindWidget(DWidget *parent) : DFloatingWidget(parent) , m_parentWidget(parent) { + qDebug() << "FindWidget created, parent:" << parent; setMinimumSize(QSize(414, 60)); setBlurBackgroundEnabled(true); @@ -31,6 +33,7 @@ FindWidget::FindWidget(DWidget *parent) FindWidget::~FindWidget() { + qDebug() << "FindWidget destroyed"; } void FindWidget::setDocSheet(DocSheet *sheet) @@ -40,6 +43,7 @@ void FindWidget::setDocSheet(DocSheet *sheet) void FindWidget::updatePosition() { + qDebug() << "Updating find widget position, yOffset:" << m_yOff; QRect screenGeometry = QGuiApplication::primaryScreen()->geometry(); this->move(screenGeometry.width() - this->width() - 10, m_yOff + 10); @@ -54,6 +58,7 @@ void FindWidget::setSearchEditFocus() void FindWidget::onSearchStop() { + qDebug() << "Search stopped, last search text:" << (m_lastSearchText.isEmpty() ? "empty" : "non-empty"); m_lastSearchText.clear(); m_findPrevButton->setDisabled(true); @@ -67,6 +72,7 @@ void FindWidget::onSearchStop() void FindWidget::onSearchStart() { + qDebug() << "Search started, text:" << (m_pSearchEdit->text().isEmpty() ? "empty" : "non-empty"); QString searchText = m_pSearchEdit->text().trimmed(); if ((searchText != "") && (m_lastSearchText != searchText)) { @@ -80,12 +86,14 @@ void FindWidget::onSearchStart() void FindWidget::slotFindNextBtnClicked() { + qDebug() << "Find next result triggered"; if (m_docSheet) m_docSheet->jumpToNextSearchResult(); } void FindWidget::slotFindPrevBtnClicked() { + qDebug() << "Find previous result triggered"; if (m_docSheet) m_docSheet->jumpToPrevSearchResult(); } @@ -99,6 +107,7 @@ void FindWidget::onTextChanged() void FindWidget::initWidget() { + qDebug() << "Initializing find widget controls"; m_pSearchEdit = new DSearchEdit(this); m_pSearchEdit->setObjectName("findSearchEdit_P"); m_pSearchEdit->lineEdit()->setObjectName("findSearchEdit"); @@ -173,6 +182,7 @@ void FindWidget::initWidget() setFixedSize(422, 60); #endif Utils::setObjectNoFocusPolicy(this); + qDebug() << "Find widget controls initialized"; } void FindWidget::setEditAlert(const int &iFlag) @@ -194,6 +204,7 @@ void FindWidget::setYOff(int yOff) void FindWidget::onCloseBtnClicked() { + qDebug() << "Find widget close button clicked"; onSearchStop(); m_pSearchEdit->clear(); diff --git a/reader/widgets/HandleMenu.cpp b/reader/widgets/HandleMenu.cpp index 34d58a8d..b1c8834f 100644 --- a/reader/widgets/HandleMenu.cpp +++ b/reader/widgets/HandleMenu.cpp @@ -6,15 +6,18 @@ #include "HandleMenu.h" #include "DocSheet.h" #include +#include HandleMenu::HandleMenu(DWidget *parent) : DMenu(parent) { + qDebug() << "HandleMenu created, parent:" << parent; initActions(); } void HandleMenu::initActions() { + qDebug() << "Initializing handle menu actions"; m_docSheet = nullptr; QActionGroup *actionGroup = new QActionGroup(this); @@ -33,22 +36,27 @@ void HandleMenu::initActions() actionGroup->addAction(m_handAction); addAction(m_handAction); + qDebug() << "Handle menu actions initialized"; } void HandleMenu::onHandTool() { + qDebug() << "Hand tool selected"; if (m_docSheet) m_docSheet->setMouseShape(Dr::MouseShapeHand); } void HandleMenu::onSelectText() { + qDebug() << "Text selection tool selected"; if (m_docSheet) m_docSheet->setMouseShape(Dr::MouseShapeNormal); } void HandleMenu::readCurDocParam(DocSheet *docSheet) { + qDebug() << "Reading document parameters"; + m_docSheet = docSheet; if (!docSheet) return; diff --git a/reader/widgets/PagingWidget.cpp b/reader/widgets/PagingWidget.cpp index 165c4882..8e80f10c 100644 --- a/reader/widgets/PagingWidget.cpp +++ b/reader/widgets/PagingWidget.cpp @@ -6,6 +6,7 @@ #include "PagingWidget.h" #include "DocSheet.h" #include "TMFunctionThread.h" +#include #include @@ -18,6 +19,7 @@ PagingWidget::PagingWidget(DocSheet *sheet, DWidget *parent) : BaseWidget(parent), m_sheet(sheet) { + qDebug() << "PagingWidget created"; initWidget(); slotUpdateTheme(); @@ -29,7 +31,7 @@ PagingWidget::PagingWidget(DocSheet *sheet, DWidget *parent) PagingWidget::~PagingWidget() { - + qDebug() << "PagingWidget destroyed"; } /** @@ -38,6 +40,7 @@ PagingWidget::~PagingWidget() */ void PagingWidget::initWidget() { + qDebug() << "Initializing paging widget"; m_pTotalPagesLab = new DLabel(this); m_pTotalPagesLab->setAccessibleName("Label_TotalPage"); @@ -94,6 +97,7 @@ void PagingWidget::initWidget() hLayout->addWidget(m_pNextPageBtn); this->setLayout(hLayout); + qDebug() << "Paging widget initialized"; } void PagingWidget::slotUpdateTheme() @@ -135,6 +139,7 @@ void PagingWidget::resizeEvent(QResizeEvent *event) void PagingWidget::setIndex(int index) { + qDebug() << "Setting page index:" << index; if (nullptr == m_sheet) return; @@ -161,6 +166,7 @@ void PagingWidget::setIndex(int index) void PagingWidget::handleOpenSuccess() { + qDebug() << "Document opened successfully, checking page labels"; if (nullptr == m_sheet) return; @@ -176,6 +182,7 @@ void PagingWidget::handleOpenSuccess() void PagingWidget::SlotJumpPageLineEditReturnPressed() { + qDebug() << "Page jump requested, hasLabel:" << m_bHasLabel; if (m_bHasLabel) { pageNumberJump(); } else { @@ -191,6 +198,7 @@ void PagingWidget::onEditFinished() void PagingWidget::normalChangePage() { + qDebug() << "Normal page change requested, text:" << m_pJumpPageLineEdit->text(); QString sText = m_pJumpPageLineEdit->text(); int iPage = sText.toInt(); if (iPage <= 0 || iPage > m_sheet->pageCount()) { @@ -202,6 +210,7 @@ void PagingWidget::normalChangePage() void PagingWidget::pageNumberJump() { + qDebug() << "Page number jump requested, text:" << m_pJumpPageLineEdit->text(); int nPageSum = m_sheet->pageCount(); QString sText = m_pJumpPageLineEdit->text(); int iPage = m_sheet->getIndexByPageLable(sText); @@ -215,11 +224,13 @@ void PagingWidget::pageNumberJump() void PagingWidget::slotPrePageBtnClicked() { + qDebug() << "Previous page button clicked"; m_sheet->jumpToPrevPage(); } void PagingWidget::slotNextPageBtnClicked() { + qDebug() << "Next page button clicked"; m_sheet->jumpToNextPage(); } @@ -232,6 +243,7 @@ void PagingWidget::setTabOrderWidget(QList &tabWidgetlst) void PagingWidget::onFuncThreadFinished() { + qDebug() << "Page label check completed, hasLabel:" << m_tmFuncThread->result.toBool(); m_bHasLabel = m_tmFuncThread->result.toBool(); m_pCurrentPageLab->setVisible(m_bHasLabel); int currentIndex = m_sheet->currentIndex(); diff --git a/reader/widgets/ProgressDialog.cpp b/reader/widgets/ProgressDialog.cpp index 5a7983bd..3ad112d0 100644 --- a/reader/widgets/ProgressDialog.cpp +++ b/reader/widgets/ProgressDialog.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "ProgressDialog.h" +#include #include #include @@ -13,6 +14,7 @@ ProgressDialog::ProgressDialog(QWidget *parent): DDialog(parent) { + qDebug() << "ProgressDialog created, parent:" << parent; setFixedSize(440, 100); QMargins mar(0, 0, 0, 30); diff --git a/reader/widgets/RoundColorWidget.cpp b/reader/widgets/RoundColorWidget.cpp index dbb56abd..94120866 100644 --- a/reader/widgets/RoundColorWidget.cpp +++ b/reader/widgets/RoundColorWidget.cpp @@ -4,6 +4,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "RoundColorWidget.h" +#include #include @@ -19,10 +20,12 @@ RoundColorWidget::RoundColorWidget(const QColor &color, QWidget *parent) , m_isSelected(false) , m_color(color) { + qDebug() << "RoundColorWidget created, color:" << color.name() << ", parent:" << parent; } void RoundColorWidget::setSelected(bool selected) { + qDebug() << "RoundColorWidget selection changed from" << m_isSelected << "to" << selected; if (m_isSelected == selected) return; @@ -33,6 +36,7 @@ void RoundColorWidget::setSelected(bool selected) void RoundColorWidget::mousePressEvent(QMouseEvent *event) { + qDebug() << "RoundColorWidget clicked, selected:" << m_isSelected << ", allNotify:" << m_allnotify; if (event->button() == Qt::LeftButton) { if (m_isSelected && !m_allnotify) return; Q_EMIT clicked(); diff --git a/reader/widgets/SaveDialog.cpp b/reader/widgets/SaveDialog.cpp index 8144e277..989c1c4f 100644 --- a/reader/widgets/SaveDialog.cpp +++ b/reader/widgets/SaveDialog.cpp @@ -4,6 +4,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "SaveDialog.h" +#include #include @@ -12,11 +13,12 @@ DWIDGET_USE_NAMESPACE SaveDialog::SaveDialog(QObject *parent) : QObject(parent) { - + qDebug() << "SaveDialog created, parent:" << parent; } int SaveDialog::showExitDialog(QString fileName, QWidget *parent) { + qDebug() << "Showing save dialog for file:" << fileName << ", parent:" << parent; DDialog dlg(tr("Save the changes to \"%1\"?").arg(fileName), "", parent); dlg.setIcon(QIcon::fromTheme("deepin-reader")); dlg.addButtons(QStringList() << tr("Cancel", "button") << tr("Discard", "button")); @@ -24,11 +26,13 @@ int SaveDialog::showExitDialog(QString fileName, QWidget *parent) QMargins mar(12, 12, 12, 12); dlg.setContentLayoutContentsMargins(mar); int nRes = dlg.exec(); + qDebug() << "Save dialog result:" << nRes; return nRes; } int SaveDialog::showTipDialog(const QString &content, QWidget *parent) { + qDebug() << "Showing tip dialog, content:" << content; DDialog dlg(content, "", parent); dlg.setIcon(QIcon::fromTheme("deepin-reader")); dlg.addButtons(QStringList() << tr("Cancel")); diff --git a/reader/widgets/ScaleMenu.cpp b/reader/widgets/ScaleMenu.cpp index abb08bf7..779d5edd 100644 --- a/reader/widgets/ScaleMenu.cpp +++ b/reader/widgets/ScaleMenu.cpp @@ -5,16 +5,20 @@ #include "ScaleMenu.h" #include "DocSheet.h" +#include ScaleMenu::ScaleMenu(QWidget *parent) : DMenu(parent) { - + qDebug() << "ScaleMenu created, parent:" << parent; } void ScaleMenu::readCurDocParam(DocSheet *docSheet) { - if (docSheet == nullptr) + qDebug() << "Reading document parameters"; + if (docSheet == nullptr) { + qDebug() << "No document sheet found, return"; return; + } m_sheet = docSheet; m_pTwoPageAction = createAction(tr("Two-Page View"), SLOT(onTwoPage()), true); @@ -45,10 +49,14 @@ void ScaleMenu::readCurDocParam(DocSheet *docSheet) m_pFitWorHAction->setChecked(docSheet->operation().scaleMode == Dr::FitToPageWorHMode); m_pFiteWAction->setChecked(docSheet->operation().scaleMode == Dr::FitToPageWidthMode); m_pFiteHAction->setChecked(docSheet->operation().scaleMode == Dr::FitToPageHeightMode); + qDebug() << "Current scale mode:" << docSheet->operation().scaleMode + << ", layout mode:" << docSheet->operation().layoutMode + << ", scale factor:" << docSheet->operation().scaleFactor; } void ScaleMenu::onTwoPage() { + qDebug() << "Two page mode selected, checked:" << m_pTwoPageAction->isChecked(); if (m_sheet == nullptr) return; @@ -61,30 +69,35 @@ void ScaleMenu::onTwoPage() void ScaleMenu::onFiteH() { + qDebug() << "Fit height mode selected"; if (m_sheet) m_sheet->setScaleMode(Dr::FitToPageHeightMode); } void ScaleMenu::onFiteW() { + qDebug() << "Fit width mode selected"; if (m_sheet) m_sheet->setScaleMode(Dr::FitToPageWidthMode); } void ScaleMenu::onDefaultPage() { + qDebug() << "Default size (1:1) selected"; if (m_sheet) m_sheet->setScaleMode(Dr::FitToPageDefaultMode); } void ScaleMenu::onFitPage() { + qDebug() << "Fit page mode selected"; if (m_sheet) m_sheet->setScaleMode(Dr::FitToPageWorHMode); } void ScaleMenu::onScaleFactor() { + qDebug() << "Scale factor selected"; if (m_sheet == nullptr) return; @@ -98,6 +111,7 @@ void ScaleMenu::onScaleFactor() QAction *ScaleMenu::createAction(const QString &objName, const char *member, bool checkable) { + qDebug() << "Creating action:" << objName << ", checkable:" << checkable; QAction *action = new QAction(objName, this); action->setObjectName(objName); action->setCheckable(checkable); diff --git a/reader/widgets/ScaleWidget.cpp b/reader/widgets/ScaleWidget.cpp index 7129c30a..99f642ce 100644 --- a/reader/widgets/ScaleWidget.cpp +++ b/reader/widgets/ScaleWidget.cpp @@ -4,6 +4,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "ScaleWidget.h" +#include #include #include @@ -17,12 +18,13 @@ ScaleWidget::ScaleWidget(DWidget *parent) : DWidget(parent) { + qDebug() << "ScaleWidget created, parent:" << parent; initWidget(); } ScaleWidget::~ScaleWidget() { - + qDebug() << "ScaleWidget destroyed"; } void ScaleWidget::initWidget() @@ -81,6 +83,7 @@ void ScaleWidget::initWidget() void ScaleWidget::onPrevScale() { + qDebug() << "Zoom out requested"; if (m_sheet.isNull()) return; @@ -89,6 +92,7 @@ void ScaleWidget::onPrevScale() void ScaleWidget::onNextScale() { + qDebug() << "Zoom in requested"; if (m_sheet.isNull()) return; @@ -97,6 +101,7 @@ void ScaleWidget::onNextScale() void ScaleWidget::onReturnPressed() { + qDebug() << "Scale value entered:" << m_lineEdit->text(); if (m_sheet.isNull()) return; @@ -107,6 +112,7 @@ void ScaleWidget::onReturnPressed() void ScaleWidget::onArrowBtnlicked() { + qDebug() << "Scale menu button clicked"; m_lineEdit->lineEdit()->setFocus(Qt::MouseFocusReason); ScaleMenu scaleMenu; @@ -131,6 +137,7 @@ void ScaleWidget::onSizeModeChanged(DGuiApplicationHelper::SizeMode sizeMode) void ScaleWidget::onEditFinished() { + qDebug() << "Scale edit finished, current scale:" << m_sheet->operation().scaleFactor; if (nullptr == m_sheet) return; @@ -140,6 +147,7 @@ void ScaleWidget::onEditFinished() void ScaleWidget::setSheet(DocSheet *sheet) { + qDebug() << "Setting document sheet:" << (sheet ? "valid" : "null"); m_sheet = sheet; if (nullptr == sheet) return; diff --git a/reader/widgets/SecurityDialog.cpp b/reader/widgets/SecurityDialog.cpp index 7f9e59fa..07f44075 100644 --- a/reader/widgets/SecurityDialog.cpp +++ b/reader/widgets/SecurityDialog.cpp @@ -4,6 +4,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "SecurityDialog.h" +#include #include #include @@ -51,6 +52,7 @@ NewStr autoCutText(const QString &text, DLabel *pDesLbl) SecurityDialog::SecurityDialog(const QString &urlstr, QWidget *parent) : DDialog(parent) { + qDebug() << "SecurityDialog created for URL:" << urlstr << ", parent:" << parent; setFixedWidth(380); setMinimumHeight(180); setIcon(QIcon::fromTheme("deepin-reader")); @@ -86,6 +88,7 @@ SecurityDialog::SecurityDialog(const QString &urlstr, QWidget *parent) void SecurityDialog::autoFeed() { + qDebug() << "Auto feed processing for text:" << m_strDesText; if (nullptr == NameLabel || nullptr == ContentLabel) { return; } @@ -108,6 +111,7 @@ void SecurityDialog::autoFeed() void SecurityDialog::setLabelColor(DLabel *label, qreal alphaF) { + qDebug() << "Setting label color with alpha:" << alphaF << ", label:" << (label ? "valid" : "null"); if (nullptr == label) { return; } @@ -121,6 +125,7 @@ void SecurityDialog::setLabelColor(DLabel *label, qreal alphaF) void SecurityDialog::changeEvent(QEvent *event) { + qDebug() << "Change event received, type:" << event->type(); if (QEvent::FontChange == event->type()) { autoFeed(); } else if (QEvent::ThemeChange == event->type()) { // 根据主题变化重新设置颜色 diff --git a/reader/widgets/ShortCutShow.cpp b/reader/widgets/ShortCutShow.cpp index d00ec95e..6b04fe4e 100644 --- a/reader/widgets/ShortCutShow.cpp +++ b/reader/widgets/ShortCutShow.cpp @@ -7,6 +7,7 @@ #include "Application.h" #include "Global.h" #include "DocSheet.h" +#include #include @@ -19,11 +20,12 @@ ShortCutShow::ShortCutShow(QObject *parent) : QObject(parent) { - + qDebug() << "ShortCutShow created, parent:" << parent; } void ShortCutShow::setSheet(DocSheet *sheet) { + qDebug() << "Setting sheet type:" << (sheet ? sheet->fileType() : -1); if (nullptr == sheet) initPDF(); else if (Dr::DJVU == sheet->fileType()) @@ -34,6 +36,7 @@ void ShortCutShow::setSheet(DocSheet *sheet) void ShortCutShow::show() { + qDebug() << "Showing shortcut viewer with" << m_shortcutMap.size() << "shortcut groups"; QRect rect = QGuiApplication::primaryScreen()->geometry(); QPoint pos(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); #if (DTK_VERSION >= DTK_VERSION_CHECK(5, 5, 2, 0)) @@ -87,6 +90,7 @@ void ShortCutShow::show() void ShortCutShow::initDJVU() { + qDebug() << "Initializing DJVU shortcuts"; initPDF(); //remove Dr::key_ctrl_f m_shortcutMap[ShortCutType::Tools].removeKey(Dr::key_ctrl_f); @@ -94,6 +98,7 @@ void ShortCutShow::initDJVU() void ShortCutShow::initPDF() { + qDebug() << "Initializing PDF shortcuts"; m_shortcutMap = { //Settings {ShortCutType::Settings, { diff --git a/reader/widgets/SlidePlayWidget.cpp b/reader/widgets/SlidePlayWidget.cpp index 1a1f5464..01947779 100644 --- a/reader/widgets/SlidePlayWidget.cpp +++ b/reader/widgets/SlidePlayWidget.cpp @@ -5,6 +5,7 @@ #include "SlidePlayWidget.h" #include "Utils.h" +#include #include #include @@ -16,11 +17,13 @@ SlidePlayWidget::SlidePlayWidget(QWidget *parent) : DFloatingWidget(parent) { + qDebug() << "SlidePlayWidget created, parent:" << parent; initControl(); } void SlidePlayWidget::initControl() { + qDebug() << "Initializing slide play controls"; setBlurBackgroundEnabled(true); setFramRadius(18); @@ -150,12 +153,14 @@ DIconButton *SlidePlayWidget::createBtn(const QString &strname) void SlidePlayWidget::setPlayStatus(bool play) { + qDebug() << "Setting play status:" << play; m_autoPlay = play; playStatusChanged(); } void SlidePlayWidget::updateProcess(int cur, int total) { + qDebug() << "Updating slide position, current:" << cur << ", total:" << total; /* 幻灯片放映时 * cur:当前页、total总页数 * 当cur:0, total:3 @@ -183,6 +188,7 @@ void SlidePlayWidget::updateProcess(int cur, int total) void SlidePlayWidget::Notify(const QString &text) { + qDebug() << "Showing notification:" << text; if(nullptr == m_dbusNotify) { m_dbusNotify = new QDBusInterface("com.deepin.dde.Notification", "/com/deepin/dde/Notification", @@ -209,27 +215,32 @@ bool SlidePlayWidget::getPlayStatus() void SlidePlayWidget::onPreClicked() { + qDebug() << "Previous button clicked"; emit signalPreBtnClicked(); } void SlidePlayWidget::onPlayClicked() { + qDebug() << "Play button clicked, new state:" << !m_autoPlay; m_autoPlay = !m_autoPlay; playStatusChanged(); } void SlidePlayWidget::onNextClicked() { + qDebug() << "Next button clicked"; emit signalNextBtnClicked(); } void SlidePlayWidget::onExitClicked() { + qDebug() << "Exit button clicked"; emit signalExitBtnClicked(); } void SlidePlayWidget::playStatusChanged() { + qDebug() << "Play status changed to:" << m_autoPlay; if (m_autoPlay) { m_playBtn->setIcon(QIcon::fromTheme(QString("dr_") + "suspend_normal")); } else { diff --git a/reader/widgets/SlideWidget.cpp b/reader/widgets/SlideWidget.cpp index 144155f4..a6178ac4 100644 --- a/reader/widgets/SlideWidget.cpp +++ b/reader/widgets/SlideWidget.cpp @@ -29,6 +29,7 @@ SlideWidget::SlideWidget(DocSheet *docsheet) : DWidget(MainWindow::windowContainSheet(docsheet)) , m_docSheet(docsheet) { + qDebug() << "SlideWidget created, initial page:" << docsheet->currentIndex(); initControl(); initImageControl(); show(); @@ -36,6 +37,7 @@ SlideWidget::SlideWidget(DocSheet *docsheet) SlideWidget::~SlideWidget() { + qDebug() << "SlideWidget destroyed"; setWidgetState(false); } @@ -185,6 +187,7 @@ void SlideWidget::mouseMoveEvent(QMouseEvent *event) void SlideWidget::setWidgetState(bool full) { + qDebug() << "Setting widget state, fullscreen:" << full; if (m_parentIsDestroyed || !parentWidget()) return; @@ -201,6 +204,7 @@ void SlideWidget::setWidgetState(bool full) void SlideWidget::onPreBtnClicked() { + qDebug() << "Previous button clicked, current page:" << m_curPageIndex; //已到第一页时,再次点击上一页按钮 if(m_curPageIndex <= 0) { m_slidePlayWidget->updateProcess(m_curPageIndex - 1, m_docSheet->pageCount()); @@ -222,6 +226,7 @@ void SlideWidget::onPreBtnClicked() void SlideWidget::onPlayBtnClicked() { + qDebug() << "Play button clicked, new state:" << !m_slidePlayWidget->getPlayStatus(); if (m_slidePlayWidget->getPlayStatus()) { //最后一页点播放时,则返回开始播放 if(m_curPageIndex >= m_docSheet->pageCount() - 1) { @@ -238,6 +243,7 @@ void SlideWidget::onPlayBtnClicked() void SlideWidget::onNextBtnClicked() { + qDebug() << "Next button clicked, current page:" << m_curPageIndex; //已到最后一页时,再次点击下一页按钮 if(m_curPageIndex >= m_docSheet->pageCount() - 1) { m_slidePlayWidget->updateProcess(m_curPageIndex + 1, m_docSheet->pageCount()); @@ -258,11 +264,14 @@ void SlideWidget::onNextBtnClicked() void SlideWidget::onExitBtnClicked() { + qDebug() << "Exit button clicked"; m_docSheet->closeSlide(); } void SlideWidget::playImage() { + qDebug() << "Playing image, from:" << m_preIndex << "to:" << m_curPageIndex + << "direction:" << (m_blefttoright ? "right" : "left"); m_imageAnimation->stop(); if (m_preIndex <= m_curPageIndex) { //正序切换(包括第一页切到最后一页) @@ -286,6 +295,7 @@ void SlideWidget::playImage() void SlideWidget::onImageShowTimeOut() { + qDebug() << "Image show timeout, moving to next page"; m_preIndex = m_curPageIndex; m_curPageIndex++; @@ -361,6 +371,7 @@ void SlideWidget::handleKeyPressEvent(const QString &sKey) void SlideWidget::onFetchImage(int index) { + qDebug() << "Fetching image for page:" << index; const QPixmap &pix = ReaderImageThreadPoolManager::getInstance()->getImageForDocSheet(m_docSheet, index); if (!pix.isNull() && qMax(pix.width(), pix.height()) == qMin(this->width() - 40, this->height() - 20)) { @@ -380,6 +391,8 @@ void SlideWidget::onFetchImage(int index) void SlideWidget::onUpdatePageImage(int pageIndex) { + qDebug() << "Updating page image:" << pageIndex + << "current:" << m_curPageIndex << "previous:" << m_preIndex; if (pageIndex == m_preIndex) { const QPixmap &lPix = ReaderImageThreadPoolManager::getInstance()->getImageForDocSheet(m_docSheet, pageIndex); m_lpixmap = drawImage(lPix); diff --git a/reader/widgets/TextEditWidget.cpp b/reader/widgets/TextEditWidget.cpp index 56d6f524..dbd5d46a 100644 --- a/reader/widgets/TextEditWidget.cpp +++ b/reader/widgets/TextEditWidget.cpp @@ -12,6 +12,7 @@ #include "Application.h" #include "Utils.h" #include "DBusObject.h" +#include #include #include @@ -27,6 +28,7 @@ TextEditShadowWidget::TextEditShadowWidget(QWidget *parent) : DWidget(parent) { + qDebug() << "TextEditShadowWidget created, parent:" << parent; setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow); setAttribute(Qt::WA_TranslucentBackground); @@ -92,6 +94,7 @@ void TextEditShadowWidget::slotCloseNoteWidget(bool isEsc) TextEditWidget::TextEditWidget(DWidget *parent) : BaseWidget(parent) { + qDebug() << "TextEditWidget created"; setAttribute(Qt::WA_TranslucentBackground); initWidget(); @@ -121,6 +124,7 @@ void TextEditWidget::onShowMenu() void TextEditWidget::setEditText(const QString ¬e) { + qDebug() << "Setting edit text, length:" << note.length(); m_pTextEdit->clear(); m_pTextEdit->setPlainText(note); m_strNote = note; @@ -132,6 +136,7 @@ void TextEditWidget::setEditText(const QString ¬e) void TextEditWidget::setAnnotation(deepin_reader::Annotation *annotation) { + qDebug() << "Setting annotation, type:" << (annotation ? annotation->type() : -1); m_annotation = annotation; } @@ -156,6 +161,7 @@ TransparentTextEdit *TextEditWidget::getTextEdit() const void TextEditWidget::hideEvent(QHideEvent *event) { + qDebug() << "TextEditWidget hiding"; BaseWidget::hideEvent(event); QString sText = m_pTextEdit->toPlainText().trimmed(); @@ -265,6 +271,7 @@ void TextEditWidget::paintEvent(QPaintEvent *event) void TextEditWidget::focusOutEvent(QFocusEvent *event) { + qDebug() << "TextEditWidget focus out, reason:" << event->reason(); BaseWidget::focusOutEvent(event); Q_EMIT sigCloseNoteWidget(); diff --git a/reader/widgets/TipsWidget.cpp b/reader/widgets/TipsWidget.cpp index 0ef93e0a..83f6e727 100644 --- a/reader/widgets/TipsWidget.cpp +++ b/reader/widgets/TipsWidget.cpp @@ -4,6 +4,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "TipsWidget.h" +#include #include #include @@ -15,6 +16,7 @@ TipsWidget::TipsWidget(QWidget *parent) : DWidget(parent) { + qDebug() << "TipsWidget created, parent:" << parent; m_parent = parent; setWindowFlags(Qt::ToolTip); initWidget(); @@ -41,6 +43,7 @@ void TipsWidget::initWidget() void TipsWidget::onUpdateTheme() { + qDebug() << "Updating tips widget theme"; DPalette plt = Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette(); plt.setColor(Dtk::Gui::DPalette::Window, plt.color(Dtk::Gui::DPalette::Base)); setPalette(plt); @@ -48,6 +51,7 @@ void TipsWidget::onUpdateTheme() void TipsWidget::setText(const QString &text) { + qDebug() << "Setting tips text, length:" << text.length(); m_text = text; m_text.replace(QChar('\n'), QString("")); m_text.replace(QChar('\t'), QString("")); @@ -103,6 +107,7 @@ void TipsWidget::adjustContent(const QString &text) void TipsWidget::showEvent(QShowEvent *event) { + qDebug() << "TipsWidget showing, autoChecked:" << m_autoChecked; DWidget::showEvent(event); if (m_autoChecked) m_timer.start(); @@ -110,6 +115,7 @@ void TipsWidget::showEvent(QShowEvent *event) void TipsWidget::hideEvent(QHideEvent *event) { + qDebug() << "TipsWidget hiding"; DWidget::hideEvent(event); m_timer.stop(); } @@ -121,6 +127,7 @@ void TipsWidget::setAutoChecked(bool autoChecked) void TipsWidget::onTimeOut() { + qDebug() << "TipsWidget timeout check, visible:" << isVisible(); if (this->isVisible() && ((m_parent && !m_parent->rect().contains(m_parent->mapFromGlobal(QCursor::pos()))) || DApplication::widgetAt(QCursor::pos()) == nullptr)) { this->hide(); } diff --git a/reader/widgets/TransparentTextEdit.cpp b/reader/widgets/TransparentTextEdit.cpp index 16d7a1c9..c2d02c72 100644 --- a/reader/widgets/TransparentTextEdit.cpp +++ b/reader/widgets/TransparentTextEdit.cpp @@ -6,6 +6,7 @@ #include "TransparentTextEdit.h" #include "Application.h" #include "MsgHeader.h" +#include #include @@ -19,6 +20,7 @@ TransparentTextEdit::TransparentTextEdit(DWidget *parent) : QTextEdit(parent) { + qDebug() << "TransparentTextEdit created, parent:" << parent; this->setObjectName("TransparentTextEdit"); this->setAcceptRichText(false); @@ -47,6 +49,7 @@ TransparentTextEdit::TransparentTextEdit(DWidget *parent) void TransparentTextEdit::slotTextEditMaxContantNum() { + qDebug() << "Checking text content length, max:" << m_nMaxContantLen; QString textContent = this->toPlainText(); int length = textContent.count(); @@ -117,12 +120,14 @@ void TransparentTextEdit::paintEvent(QPaintEvent *event) void TransparentTextEdit::insertFromMimeData(const QMimeData *source) { + qDebug() << "Inserting from mime data, has text:" << !source->text().isEmpty(); if (!source->text().isEmpty()) this->insertPlainText(source->text()); } void TransparentTextEdit::keyPressEvent(QKeyEvent *keyEvent) { + qDebug() << "Key pressed:" << keyEvent->key() << "modifiers:" << keyEvent->modifiers(); if (keyEvent->key() == Qt::Key_M && (keyEvent->modifiers() & Qt::AltModifier) && !keyEvent->isAutoRepeat()) { QMenu *menu = this->createStandardContextMenu(); @@ -139,6 +144,7 @@ void TransparentTextEdit::keyPressEvent(QKeyEvent *keyEvent) void TransparentTextEdit::focusOutEvent(QFocusEvent *event) { + qDebug() << "Focus out event, reason:" << event->reason(); QTextEdit::focusOutEvent(event); Q_EMIT sigCloseNoteWidget(); diff --git a/reader/widgets/WordWrapLabel.cpp b/reader/widgets/WordWrapLabel.cpp index a24533b2..74771d0f 100644 --- a/reader/widgets/WordWrapLabel.cpp +++ b/reader/widgets/WordWrapLabel.cpp @@ -4,23 +4,27 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "WordWrapLabel.h" +#include #include WordWrapLabel::WordWrapLabel(QWidget *parent) : DLabel(parent) { + qDebug() << "WordWrapLabel created, parent:" << parent; m_margin = 0; } void WordWrapLabel::setText(const QString &text) { + qDebug() << "Setting label text, length:" << text.length(); m_text = text; update(); } void WordWrapLabel::setMargin(int margin) { + qDebug() << "Setting label margin:" << margin; m_margin = margin; update(); } @@ -40,6 +44,7 @@ void WordWrapLabel::paintEvent(QPaintEvent *event) void WordWrapLabel::adjustContent() { + qDebug() << "Adjusting label content height"; QFontMetrics fontMetris(this->font()); int wordHeight = fontMetris.boundingRect(0, 0, this->width() - 2 * m_margin, 0, static_cast(this->alignment() | Qt::TextWrapAnywhere), m_text).height(); if (this->height() == wordHeight) return;